我正在制作一些PHP应用程序,我想使用我的WCF服务,这是很好用的。我需要拨打肥皂,并设置标题为:
<s:Header>
<a:Action s:mustUnderstand="1">GetPage</a:Action>
<a:MessageID>1</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://someurl.com</a:To>
在我想要拨打电话的php文件中:
$ns = 'http://www.w3.org/2005/08/addressing'; //Namespace of the WS.
//Body of the Soap Header.
$headerbody = array('MessageID' => '1',
'Action' => 'GetPage',
'To' => 'http://someurl.com');
//Create Soap Header.
$header = new SOAPHeader($ns, $headerbody);
//set the Headers of Soap Client.
$soapClient->__setSoapHeaders($header);
$GetPageResponse = $soapClient->GetPage($GetPageRequest);
当我查看我的服务日志时,我发现收到的消息如下:
<SOAP-ENV:Envelope xmlns:SOAP- ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Flow/2012/10">
<SOAP-ENV:Header>
<To SOAP-ENV:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://someurl.com</To>
<Action SOAP-ENV:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">urn:Flow/2012/10/GetPage</Action>
</SOAP-ENV:Header>
</SOAP-ENV:Envelope>
$ GetPageRequest目前无关紧要。所以,在我的标题中没有MessageID。我在这里错过了什么?我做错了吗?另外,如何正确设置部分“回复”?
答案 0 :(得分:0)
不确定为什么MessageID还没有通过你的输出,但是添加ReplyTo-&gt;地址就像在你的标题数组中添加一个子数组一样简单。
$headerbody = array('MessageID' => '1',
'Action' => 'GetPage',
'To' => 'http://someurl.com',
'ReplyTo' => array (
'Address' => 'http://www.w3.org/2005/08/addressing/anonymous'
)
);