如何创建SOAP 1.2请求

4

我需要帮助创建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>

非常感谢。
2个回答

10
<?php
    $client = new SoapClient("URL/OF/YOUR/WSDL", array('soap_version' => SOAP_1_2));
    $result = $client('GetProducts');
?>

1
这就是我正在寻找的答案。 - Player1

0

我希望这个例子能帮助你解决问题。祝一切顺利!

// 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));

1
欢迎来到SO!请解释一下你的代码是做什么的,否则没有人能够学到东西,只会继续复制和粘贴,这不是我们的目标。 - Hille

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接