AFAS Profit SOAP connectie
Ik probeer met AFAS Profit via SOAP connectie te maken. Ik moet de volgende wsdl gebruiken volgens AFAS.
https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl
Als ik deze URL in de browser invoer, moet ik eerst inloggen voordat ik de wsdl te zien krijg. Dus gebruik ik in PHP de login methode als:
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$wsdl = "https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl";
$login = 'gebruikersnaam';
$password = 'wachtwoord';
$client = new SoapClient( $wsdl, array('login' => $login, 'password' => $password, 'trace' => 1, 'exceptions' => 0));
?>
$wsdl = "https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl";
$login = 'gebruikersnaam';
$password = 'wachtwoord';
$client = new SoapClient( $wsdl, array('login' => $login, 'password' => $password, 'trace' => 1, 'exceptions' => 0));
?>
Ik krijg dan echter deze foutmelding:
Warning: SoapClient::SoapClient(https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized ( The server requires authorization to fulfill the request. Access to the Web server is denied. Cont in C:\xampp\htdocs\test.nl\soap.php on line 9
Warning: SoapClient::SoapClient(): I/O warning : failed to load external entity "https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl" in C:\xampp\htdocs\test.nl\soap.php on line 9
Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl' : failed to load external entity "https://profitweb.afasonline.nl/profitservices/updateconnector.asmx?wsdl" in C:\xampp\htdocs\test.nl\soap.php on line 9
Hoe krijg ik connectie met deze SOAP service..?
Gewijzigd op 13/02/2014 11:55:31 door Thijm Post
Lijkt er op dat je eerst moet inloggen.
@SanThe, dat lijkt mij inderdaad ook, en dat doe ik ook. Maar hij weigert...
Is het je gelukt ?
Zoja wil je de code delen ?
Ik loop tegen een "There is no value entered in mandatory field 'Code' (Id)" error aan.
Mogelijk heb jij een werkende update connector.
Is het al gelukt om connectie te maken met Afas? Ik zit hier nu namelijk ook mee te stoeien om connectie te maken met de GetConnector, alleen lukt het mij ook niet om het gebruikersnaam en wachtwoord mee te geven en in te loggen op die pagina om gebruik te maken van deze connector.
Ik hoor graag van je!
Groet Jeroen
http://webbio.nl/wikiweb/afasonline-soap-authentication-issue-in-php-and-how-to-resolve-it/
Basically you get these kind of errors when you connect with Afasonline Soap API in PHP
Below is an example how to connect and request
NOTE: First you need to know some concept about Afasonline API before connecting as you know Afasonline uses Nusoap with Windows NTLM Authentication so in order connect you need domain name for NTLM which is “AOL” in case Afasonline. You can read more about NTLM by searching over the internet. Further you need the following parameter also in order to connect environmentId (it always starts with OXXXXXXX), userId, Password, connectorID.
I am going show an example for Getconnector with connectorID (SSS_werkgever_vacatures) to get all the jobs but method of authentication is same for all the connectors.
For Detailed Tutorial go here Basically you get these kind of errors when you connect with Afasonline Soap API in PHP
Below is an example how to connect and request
NOTE: First you need to know some concept about Afasonline API before connecting as you know Afasonline uses Nusoap with Windows NTLM Authentication so in order connect you need domain name for NTLM which is “AOL” in case Afasonline. You can read more about NTLM by searching over the internet. Further you need the following parameter also in order to connect environmentId (it always starts with OXXXXXXX), userId, Password, connectorID.
I am going show an example for Getconnector with connectorID (SSS_werkgever_vacatures) to get all the jobs but method of authentication is same for all the connectors.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once('lib/nusoap.php');
$wsdl = 'https://profitweb.afasonline.nl/profitservices/getconnector.asmx?wsdl';
$client = new nusoap_client($wsdl, true);
$client->setCredentials("AOL" . '\\' . "knip.knip", "Knip!", 'ntlm');
$client->setUseCurl(true);
$client->useHTTPPersistentConnection();
$client->setCurlOption(CURLOPT_USERPWD, 'knip.knip:knip!');
$xml_array['environmentId'] = 'O12343AA';
$xml_array['userId'] = "knip.knip";
$xml_array['password'] = "Password";
$xml_array['logonAs'] = "";
$xml_array['connectorId'] = "SSS_werkgever_vacatures";
$xml_array['filtersXml'] = "";
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
exit();
}
$result = $client->call('GetData', array('parameters' => $xml_array), '', '', false, true);
// var_dump($result);
header('Content-Type: application/xml');
print_r($result["GetDataResult"]);
?>
require_once('lib/nusoap.php');
$wsdl = 'https://profitweb.afasonline.nl/profitservices/getconnector.asmx?wsdl';
$client = new nusoap_client($wsdl, true);
$client->setCredentials("AOL" . '\\' . "knip.knip", "Knip!", 'ntlm');
$client->setUseCurl(true);
$client->useHTTPPersistentConnection();
$client->setCurlOption(CURLOPT_USERPWD, 'knip.knip:knip!');
$xml_array['environmentId'] = 'O12343AA';
$xml_array['userId'] = "knip.knip";
$xml_array['password'] = "Password";
$xml_array['logonAs'] = "";
$xml_array['connectorId'] = "SSS_werkgever_vacatures";
$xml_array['filtersXml'] = "";
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
exit();
}
$result = $client->call('GetData', array('parameters' => $xml_array), '', '', false, true);
// var_dump($result);
header('Content-Type: application/xml');
print_r($result["GetDataResult"]);
?>
- Ariën -:
For security reasons, logincredentials removed
Gewijzigd op 01/11/2015 08:09:37 door - Ariën -
..