对 WCF 的 PHP 调用 - 肥皂标头问题


PHP call to WCF - soap header issue

我正在制作一些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目前无关紧要。因此,在我的标头中没有消息ID。我在这里错过了什么?我设置错了什么吗?另外,如何正确设置部分"回复"?

不确定为什么 MessageID 还没有在您的输出中通过,但添加 ReplyTo->Address 就像将子数组添加到标头数组一样简单。

$headerbody = array('MessageID' => '1',
                'Action' => 'GetPage',
                'To' => 'http://someurl.com',
                'ReplyTo' => array (
                      'Address' => 'http://www.w3.org/2005/08/addressing/anonymous'
                      )
                 );