Ik ben al enige tijd bezig met het opzetten van een geldige soap request naar onze elo (it's Learning) maar krijg dit met PHP niet echt voor elkaar.
Ik ben begonnen met het testen in SoapUI om in elk geval makkelijk de juiste request body te maken, en dit is mij dus ook wel gelukt. Ik krijg het nu alleen niet voor elkaar deze zelfde request in PHP in elkaar te zetten.
De soap server gebruikt een wsse beveiliging (username etc in de header dus) en ik zal dus zowel de headers als de body zelf moeten genereren.
als ik via SoapUI kijk naar een valide request ziet deze er als volgt uit :
Vrij duidelijk, echter als ik deze in PHP nabouw (ik heb het eerst in native PHP Soap geprobeerd, en ben hierna naar nuSoap over gesprongen) kom ik op de volgende code uit :
Dit genereert de volgende soap request:
wat kleine verschillen, maar voor zover ik kan beoordelen geen dealbreakers.... zou je denken.... ik krijg namelijk als antwoord het volgende terug :
Wie o wie kan mij hierbij in de goede richting schoppen, want ik kom er even niet meer uit
Ik ben begonnen met het testen in SoapUI om in elk geval makkelijk de juiste request body te maken, en dit is mij dus ook wel gelukt. Ik krijg het nu alleen niet voor elkaar deze zelfde request in PHP in elkaar te zetten.
De soap server gebruikt een wsse beveiliging (username etc in de header dus) en ik zal dus zowel de headers als de body zelf moeten genereren.
als ik via SoapUI kijk naar een valide request ziet deze er als volgt uit :
XML:
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
| POST /WCFServiceLibrary/ImsEnterpriseServicesPort.svc HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: text/xml;charset=UTF-8 SOAPAction: "http://www.imsglobal.org/soap/pms/readPerson" Content-Length: 1344 Host: soapserver Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) <soapenv:Envelope xmlns:ims="http://www.imsglobal.org/services/common/imsMessBindSchema_v1p0" xmlns:ims1="http://www.imsglobal.org/services/pms/xsd/imsPersonManMessSchema_v1p0" xmlns:ims2="http://www.imsglobal.org/services/common/imsCommonSchema_v1p0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-2"> <wsse:Username>username</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password> <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">BzyMqoa26ro/avnxOlngCw==</wsse:Nonce> <wsu:Created>2012-09-23T08:55:09.351Z</wsu:Created> </wsse:UsernameToken> </wsse:Security> <ims:syncRequestHeaderInfo> <ims:messageIdentifier>1</ims:messageIdentifier> </ims:syncRequestHeaderInfo>" </soapenv:Header> <soapenv:Body> <ims1:readPersonRequest> <ims1:sourcedId> <ims2:identifier>1234joe</ims2:identifier> </ims1:sourcedId> </ims1:readPersonRequest> </soapenv:Body> </soapenv:Envelope> |
Vrij duidelijk, echter als ik deze in PHP nabouw (ik heb het eerst in native PHP Soap geprobeerd, en ben hierna naar nuSoap over gesprongen) kom ik op de volgende code uit :
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| <?php error_reporting(E_ALL); ini_set('display_errors','On'); require_once('./lib/nusoap.php'); $username = "username"; $password = "password"; $endpoint = "https://soapserver/WCFServiceLibrary/ImsEnterpriseServicesPort.svc"; $soapaction = "http://www.imsglobal.org/soap/pms/readPerson"; $client = new nusoap_client($endpoint, false); $client->soap_defencoding = 'UTF-8'; $nonce = md5(rand()); $created = date("Y-m-d H:i:s"); $headers = ' <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken"> <wsse:Username>'.$username.'</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'.$password.'</wsse:Password> <wsse:Nonce>'.$nonce.'</wsse:Nonce> <wsu:Created>'.$created.'</wsu:Created> </wsse:UsernameToken> </wsse:Security> <ims:syncRequestHeaderInfo> <ims:messageIdentifier>1</ims:messageIdentifier> </ims:syncRequestHeaderInfo> '; $body = ' <ims1:readPersonRequest> <ims1:sourcedId> <ims2:identifier>1234joe</ims2:identifier> </ims1:sourcedId> </ims1:readPersonRequest> '; $msg = $client->serializeEnvelope($body, $headers); $result = $client->send($msg, $soapaction); // voor debugging echo '<h2>Request</h2>'; echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>'; echo '<h2>Response</h2>'; echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>'; echo '<h2>Debug</h2>'; echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>'; ?> |
Dit genereert de volgende soap request:
XML:
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
| POST /WCFServiceLibrary/ImsEnterpriseServicesPort.svc HTTP/1.0 Host: soapserver User-Agent: NuSOAP/0.9.5 (1.123) Content-Type: text/xml; charset=UTF-8 SOAPAction: "http://www.imsglobal.org/soap/pms/readPerson" Content-Length: 1313 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Header> <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken"> <wsse:Username>username</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password> <wsse:Nonce>6e875a13a2d9ede1aefbc93d057b84e5</wsse:Nonce> <wsu:Created>2012-09-23 11:00:33</wsu:Created> </wsse:UsernameToken> </wsse:Security> <ims:syncRequestHeaderInfo> <ims:messageIdentifier>1</ims:messageIdentifier> </ims:syncRequestHeaderInfo> </SOAP-ENV:Header> <SOAP-ENV:Body> <ims1:readPersonRequest> <ims1:sourcedId> <ims2:identifier>1234joe</ims2:identifier> </ims1:sourcedId> </ims1:readPersonRequest> </SOAP-ENV:Body> </SOAP-ENV:Envelope> |
wat kleine verschillen, maar voor zover ik kan beoordelen geen dealbreakers.... zou je denken.... ik krijg namelijk als antwoord het volgende terug :
code:
1
2
3
4
5
6
7
8
9
10
| HTTP/1.1 100 Continue HTTP/1.1 400 Bad Request Cache-Control: private Server: Microsoft-IIS/7.5 X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET ITSL: ITSL529 Date: Sun, 23 Sep 2012 09:00:33 GMT Content-Length: 0 |
Wie o wie kan mij hierbij in de goede richting schoppen, want ik kom er even niet meer uit