Php soap client xml request example
In this post, i will show you How to send soap envelope XML requests in PHP. No need to declare a long request array, just simple pass soap xml as request using header information. The
soap envelope contains the headers and soap body. You need to call a function or method on a web server with some parameters to process the request. Some users might get confused when seeing the soap XML request format. Like they use SOAPAction URL value as request action or don’t get the header parameters. In this tutorial, we are going to clear your confusion. Let’s see how soap envelope XML look like.
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 POST/webserviceexternal/contracts.asmx HTTP/1.1 Host:example.com Content-Type:text/xml;charset=utf-8 Content-Length:
length SOAPAction:"http://example.com/CreateItems" xml version="1.0"encoding="utf-8"?> <soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body>
<extLoginData xmlns="http://www.JOI.com/schemas/ViaSub.WMS/"> <Login>string</Login> <Password>string</Password>
</extLoginData> <Items xmlns="http://www.JOI.com/schemas/ViaSub.WMS/"> <Item>
<SKU>int</SKU> <Description>string</Description> <CustomerID>int</CustomerID>
<InventoryMethod>string</InventoryMethod> </Item> </Items>
<warnings xmlns="http://www.JOI.com/schemas/ViaSub.WMS/">string</warnings> </soap:Body> </soap:Envelope>
As you see above Host, Content-Type, Content-Length, and SoapAction, all are the header parameters. And right below is the XML request string you need to pass. Make sure you put the right value in XML parameter element. You May Also Like:How to Authenticate with D&B Direct API Web Service How to Post Soap Envelop XML Request in PHPWe can post soap XML using curl method. Define the curl request header and post the soap envelop XML data. Check the below code to execute this request.
You need to change SOAPaction and request URL as per soap envelop request pattern and call method this curl method in PHP. This is quite easy to implement this soap api call. Recommended Posts For You
About HarishI am professional web developer and blogger. Use this blog to share own api and other web development experience with you. I do accept paid work. Write to me at - View all posts by Harish |