I'am a newbie to SOAP and I was asked to building a nusoap customized client and server. Actually, I am having a problem reading the following nusoap request header.
<wsa:Action> OTA_HotelRatePlanRQ </wsa:Action>
<wsa:From>
<wsa:Address> urn:connect </wsa:Address>
</wsa:From>
<wsa:To> PartnerURL </wsa:To>
<wsa:ReplyTo>
<wsa:Address> http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous </wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID> 5f2c4c6b-642f-4d07-ad9c-02e5b5cdaa29 </wsa:MessageID>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="SecurityToken-627f1ab1-338a-451f-9829-84f248e57ad8" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username> Username </wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile1.0#PasswordText"> password </wsse:Password>
<wsu:Created> 2014-12-19T16:09:15 </wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
In fact I've had hard time managing to send it from the client side; finally, I was able to send it using serializeEnvelope() and send() nusoap functions. Right now, I can't find a way to read it from the server side. it show the following error message: "Undefined index: wsa". Can any one help me please.
Thank you
In fact I have just found a way to catch the header elements.
here is how:
$request= get_defined_vars();
$request["GLOBALS"]["GLOBALS"]["HTTP_RAW_POST_DATA"] contains all the data received at the server side.
Related
Using PHP 5.5.9, I'm trying to make a SOAP call and I cannot figure out how to add this header:
<SOAP-ENV:Header>
<wsa:Action>https://websvcs.adtrack.com/SmartLeadImport/Submit_Lead</wsa:Action>
<wsa:MessageID>urn:uuid:GUID</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:To>http://stage.adtrack.com/SmartLeadImport/SmartLeadImport.asmx?wsdl</wsa:To>
<wsse:Security SOAP-ENV:mustUnderstand="1">
<wsu:Timestamp wsu:Id="Timestamp-GUID">
<wsu:Created>2017-10-19T14:02:37Z</wsu:Created>
<wsu:Expires>2017-10-19T14:07:37Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SecurityToken-GUID">
<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">***************</wsse:Password>
<wsse:Nonce>SOMENONSENSE</wsse:Nonce>
<wsu:Created>2017-10-18T14:02:37Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
What I'm having a real problem with is the nested namespaces. I've tried a couple different approaches.
Adding the XML to a SoapVar, then making that a header, but I can't figure out how to specify namespaces.
Trying to create SoapHeaders, but those came out looking odd, and again, I don't know how to make sure all the namespaces get accounted for.
Any help with this would be amazing. Thanks.
How can I generate this schema using php soap client cant seem to get a way
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:loc="http://www.csapi.org/schema/parlayx/subscribe/manage/v1_0/local">
<soapenv:Header>
<tns:RequestSOAPHeader xmlns:tns="http://www.namesapace.com/common/v2_1">
<tns:one>***</tns:one>
<tns:two>***</tns:three>
<oauth_token>***</oauth_token>
</tns:RequestSOAPHeader>
</soapenv:Header>
<soapenv:Body>
<loc:ProductRequest>
<subInfo>
<productID>***</productID>
<isAutoExtend>0</isAutoExtend>
</subInfo>
</loc:ProductRequest>
</soapenv:Body>
</soapenv:Envelope>
On top of using the client, sometimes it may not bind to the namespace especially if using different soap versions or other strange reasons. Solved it by overriding the soap class and replacing the ns1 and ns2 values as described here http://php.net/manual/en/soapclient.dorequest.php#74123
IF no success with php soapclient, just post the request with curl.
Example in this answer - SOAP request in PHP with CURL
I'm building a PHP application that needs to connect to a webservice which requires a header in every request for authentication. How to send the following along with the requests? Do I need to use SoapHeader along with SoapClient?
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="Id-0001334008436683-000000002c4a1908-1"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<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:UsernameToken>
</wsse:Security>
</soap:Header>
The SOAP envelope has the following structure:
So, you should send a SOAP envelope that has both a Header (like the one you described) and a Body that contains the request itself.
I think you should be using setSoapHeaders on the Client. Refer to the examples in the link.
Hope this helps. Good luck!
I'm trying to get a result from a wsdl file, It however requires authentication and the normal passing of an username and password gives me an error:
Error arguments:
Missing authentication from header
The header should look like the one below;
<wsse:UsernameToken wsu:Id="UsernameToken-3">
<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">jfdkfjdskfjdsklfjsdkf==</wsse:Nonce>
<wsu:Created>TIMESTAMP</wsu:Created>
</wsse:UsernameToken>
I need a litte bit help.
I have the following two URLS:
WSDL: https://amsel.dpwn.net/abholportal/gw/lp/schema/1.0/var3ws.wsdl
Endpoint: https://amsel.dpwn.net/abholportal/gw/lp/SoapConnector
Now I want to send the server something like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:var="https://amsel.dpwn.net/abholportal/gw/lp/schema/1.0/var3bl">
<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">
<wsse:UsernameToken>
<wsse:Username>ws_online_retoure</wsse:Username>
<wsse:Password
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-tokenprofile1.0#
PasswordText">Anfang1!</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<var:BookLabelRequest
portalId="OnlineRetoure"
deliveryName="Spanien_Var3"
shipmentReference="ShipRef Nextt"
customerReference="1.Feld via Webservice"
labelFormat="PDF"
senderName1="Willi Webservice"
senderName2="via Webservice"
senderCareOfName="careOfName"
senderContactPhone="0800 123456"
senderStreet="Webservice Street"
senderStreetNumber="8080"
senderBoxNumber="12"
senderPostalCode="28010"
senderCity="Madrid"/>
</soapenv:Body>
</soapenv:Envelope>
How can I do this in PHP?
Thanks!
I had the similar problem as well due to sparse examples on how to use SOAP with PHP. Here are a couple of examples that may guide you to developing the SOAP interface.
http://bisqwit.iki.fi/story/howto/phpajaxsoap/#IsSoapTheBestWay
http://geekswithblogs.net/THines01/archive/2010/03/07/callws.aspx
http://jimmyzimmerman.com/2007/02/soap-server-with-php5-part-1.html
SOAP is clearly an overkill for many purposes in my opinion.
See NuSoap.
It simplifies the build of WebServices and clients.