【问题标题】:How to create SOAP 1.2 request如何创建 SOAP 1.2 请求
【发布时间】:2014-05-05 12:08:20
【问题描述】:

我需要有关创建 SOAP 1.2 请求的帮助。我只有这个:

样品请求:

POST /WS/PriceList.asmx HTTP/1.1
Host: gateway.systemb2b.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetProducts xmlns="http://gateway.systemb2b.com/schemas/Product" />
  </soap12:Body>
</soap12:Envelope>

示例响应:

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetProductsResponse xmlns="http://gateway.systemb2b.com/schemas/Product">
      <GetProductsResult>xml</GetProductsResult>
    </GetProductsResponse>
  </soap12:Body>
</soap12:Envelope>

非常感谢。

【问题讨论】:

    标签: php xml soap import request


    【解决方案1】:
    <?php
        $client = new SoapClient("URL/OF/YOUR/WSDL", array('soap_version' => SOAP_1_2));
        $result = $client('GetProducts');
    ?>
    

    【讨论】:

    • 这是我正在寻找的答案。
    【解决方案2】:

    我希望这个示例可以帮助您解决问题。万事如意!

    // SOAP 1.2 client
    $options = array('soap_version'=>SOAP_1_2, 'exceptions'=>true, 'trace'=>1);
    
    $client = new SoapClient('https://www.example.com/example.svc/SSL?wsdl', $options);
    
    $actionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing','Action','http://tempuri.org/xxxx/GetResult');
    
    $toActionHeader = new SoapHeader('http://www.w3.org/2005/08/addressing','To','https://www.example.com/example.svc/SSL?wsdl');
    
    $headerbody = array('Action' => $actionHeader,'To' => $toActionHeader);
               
    $client->__setSoapHeaders($headerbody);
    
    $client->__setLocation('https://www.example.com/example.svc/SSL');
    
    $params = array( "param1"=>"abc", "param2"=>"ab123",c"param3"=>"ab1111" );  
    
    $client->__soapCall("GetResult", array($params));
    

    【讨论】:

    • 欢迎来到 SO!请解释你的代码是做什么的,否则没有人能够学到东西,只是继续复制和粘贴,这不是这里的目标。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-24
    • 1970-01-01
    • 1970-01-01
    • 2014-05-22
    • 2017-03-09
    • 2019-08-16
    • 1970-01-01
    相关资源
    最近更新 更多