PHP - SOAP 1.1 request and response handling in php
I am trying to integrate netForum. It needs some SOAP requests. The following is a sample SOAP 1.1 request and response, but i don't know how to implement this in php.
Request:
POST /xweb/netFORUMXMLONDemand.asmx HTTP/1.1
Host: nftpsandbox.avectra.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.avectra.com/OnDemand/2005/NewIndividualInformation"
<?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:Header>
<AuthorizationToken xmlns="http://www.avectra.com/OnDemand/2005/">
<Token>string</Token>
</AuthorizationToken>
</soap:Header>
<soap:Body>
<NewIndividualInformation xmlns="http://www.avectra.com/OnDemand/2005/">
<oNode>xml</oNode>
</NewIndividualInformation>
</soap:Body>
</soap:Envelope>
Response -
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://w开发者_JAVA百科ww.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthorizationToken xmlns="http://www.avectra.com/OnDemand/2005/">
<Token>string</Token>
</AuthorizationToken>
</soap:Header>
<soap:Body>
<NewIndividualInformationResponse xmlns="http://www.avectra.com/OnDemand/2005/">
<NewIndividualInformationResult>xml</NewIndividualInformationResult>
</NewIndividualInformationResponse>
</soap:Body>
</soap:Envelope>
PHP has built-in support for this through the SOAP extension (activated in most recent configs). The background behind this is available through http://php.net/manual/en/book.soap.php. SOAP lets you perform remote calls as if you were performing them on your own objects so you will probably have little to do with the raw data you're posting.
Basically the functions of PHP's SOAP extensions are split into a SoapClient
class and a SoapServer
class. The former will be the one you're going to need. Have a look at http://www.php.net/manual/en/soapclient.dorequest.php and check the API docs for what kind of requests you can make.
精彩评论