Reputation: 1208
I'm trying to connect AFAS to get some datas
$soapURL = "https://80051.afasonlineconnector.nl/profitservices/appconnectorget.asmx?wsdl" ;
$soapFunction = "GetData" ;
$soapFunctionParameters = array(
'token' =>'mytokenhere',
'connectorId'=>'myconnectud',
'filtersXml' => 'urn:Afas:Profit:Services',
'skip' => 0,
'take' => 200) ;
$soapClient = new SoapClient($soapURL);
$soapResult = $soapClient->__soapCall($soapFunction,$soapFunctionParameters) ;
Above gives a Fetal error
Fatal error: Uncaught SoapFault exception: [soap:Server] Er is een onverwachte fout opgetreden. in xxxxx/afasscript/index.php:38 Stack trace: #0 xxxxxx/afasscript/index.php(38): SoapClient->__soapCall('GetData', Array) #1 {main} thrown inxxxxxx/afasscript/index.php on line 38`
I tried use try and catch but cant see actual error. The functions and parameters are like below
array(4) {
[0]=>
string(44) "GetDataResponse GetData(GetData $parameters)"
[1]=>
string(77) "GetDataWithOptionsResponse GetDataWithOptions(GetDataWithOptions $parameters)"
[2]=>
string(44) "GetDataResponse GetData(GetData $parameters)"
[3]=>
string(77) "GetDataWithOptionsResponse GetDataWithOptions(GetDataWithOptions $parameters)"
}
array(4) {
[0]=>
string(96) "struct GetData {
string token;
string connectorId;
string filtersXml;
int skip;
int take;
}"
[1]=>
string(49) "struct GetDataResponse {
string GetDataResult;
}"
[2]=>
string(124) "struct GetDataWithOptions {
string token;
string connectorId;
string filtersXml;
int skip;
int take;
string options;
}"
[3]=>
string(71) "struct GetDataWithOptionsResponse {
string GetDataWithOptionsResult;
}"
}
array(4) {
[0]=>
string(44) "GetDataResponse GetData(GetData $parameters)"
[1]=>
string(77) "GetDataWithOptionsResponse GetDataWithOptions(GetDataWithOptions $parameters)"
[2]=>
string(44) "GetDataResponse GetData(GetData $parameters)"
[3]=>
string(77) "GetDataWithOptionsResponse GetDataWithOptions(GetDataWithOptions $parameters)"
}
array(4) {
[0]=>
string(96) "struct GetData {
string token;
string connectorId;
string filtersXml;
int skip;
int take;
}"
[1]=>
string(49) "struct GetDataResponse {
string GetDataResult;
}"
[2]=>
string(124) "struct GetDataWithOptions {
string token;
string connectorId;
string filtersXml;
int skip;
int take;
string options;
}"
[3]=>
string(71) "struct GetDataWithOptionsResponse {
string GetDataWithOptionsResult;
}"
}
Did i do something wring with call the GeData function, this works well when i use online soap call services, can someone give me help to fix this please.
Thank You
Upvotes: 1
Views: 461
Reputation: 41
This question is a bit older already, but ok, still for people that encounter difficulties:
I had a similar issue and this had to do with TLS 1.2 that is necessary for a secure connection with the AFAS servers (see for an explanation below)
But first of all get your Getconnector working in the online test portal of AFAS: https://connect.afas.nl/
This is a test workbench to see if you are using the right parms. So if you issued a token and configured the rest of the app connector.
Needing help on this you may go to their knowledge center at: https://help.afas.nl/?query=Getconnector
When using the web services of AFAS please keep in mind that they use TLS1.2 secure connections. So check that you have taken care of that, if your computer does not have this enabled you have to do this:
https://learn.microsoft.com/en-us/sccm/core/plan-design/security/enable-tls-1-2#update-net-framework-to-support-tls-12 Configure for strong cryptography Configure .NET Framework to support strong cryptography. Set the SchUseStrongCrypto registry setting to DWORD:00000001. This value disables the RC4 stream cipher and requires a restart. For more information about this setting, see Microsoft Security Advisory 296038.
Make sure to set the following registry keys on any computer that communicates across the network with a TLS 1.2-enabled system. For example, Configuration Manager clients, or any remote site system role that's not installed on the site server.
For 32-bit applications that are running on 32-bit systems or 64-bit applications that are running on 64-bit systems, update the following subkey value:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]
"SystemDefaultTlsVersions" = dword:00000001
"SchUseStrongCrypto" = dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions" = dword:00000001
"SchUseStrongCrypto" = dword:00000001
For 32-bit applications that are running on 64-bit systems, update the following subkey value:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727]
"SystemDefaultTlsVersions" = dword:00000001
"SchUseStrongCrypto" = dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions" = dword:00000001
"SchUseStrongCrypto" = dword:00000001
Upvotes: 1
Reputation: 11
The error text Er is een onverwachte fout opgetreden.
comes from the AFAS server, yet the entire stack trace of the error is not passed through the API.
Therefore, you should check in Profit Windows in the Omgevingslogboek
what the entire stack trace of the error entails.
Go to Startmenu F4 / Algemeen / Omgeving / Beheer / Omgevingslogboek
Feel free to check in with the AFAS Support center or connect.afas.nl if you need any further assistance.
EDIT: Check out this repository on GitHub with a plug-and-play library for the AFAS AppConnector.
Upvotes: 1