【问题标题】:PHP - SOAP 1.1 request and response handling in phpPHP - php 中的 SOAP 1.1 请求和响应处理
【发布时间】:2011-04-29 08:50:01
【问题描述】:

我正在尝试集成 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


【解决方案1】:

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 文档,了解您可以提出哪些类型的请求。

【讨论】:

    猜你喜欢
    • 2023-01-09
    • 2019-08-16
    • 2013-04-11
    • 1970-01-01
    • 2010-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多