PHP -在PHP中处理SOAP 1.1请求和响应


PHP - SOAP 1.1 request and response handling in php

我正在尝试整合netForum。它需要一些SOAP请求。下面是一个SOAP 1.1请求和响应的示例,但是我不知道如何在php中实现它。

请求:

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>

响应-

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://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>
    <NewIndividualInformationResponse xmlns="http://www.avectra.com/OnDemand/2005/">
      <NewIndividualInformationResult>xml</NewIndividualInformationResult>
    </NewIndividualInformationResponse>
  </soap:Body>
</soap:Envelope>

PHP通过SOAP扩展(在最近的配置中激活)对此提供了内置支持。这背后的背景可通过http://php.net/manual/en/book.soap.php获得。SOAP允许您执行远程调用,就像您在自己的对象上执行它们一样,因此您可能几乎不需要处理您发布的原始数据。

基本上PHP的SOAP扩展的函数被分成一个SoapClient类和一个SoapServer类。前者将是你需要的。请查看http://www.php.net/manual/en/soapclient.dorequest.php并查看API文档,了解可以发出哪些类型的请求。