【问题标题】:PHP call to WCF - soap header issuePHP 调用 WCF - 肥皂头问题
【发布时间】:2016-01-27 10:03:40
【问题描述】:

我正在制作一些 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。我在这里想念什么?我设置错了吗?另外,如何正确设置“ReplyTo”部分?

【问题讨论】:

    标签: php wcf soap


    【解决方案1】:

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

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

    【讨论】:

    • 是的,我想应该是这样的,谢谢!我也没有,没发现问题,真奇怪..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-14
    • 2018-04-12
    • 1970-01-01
    • 2012-07-17
    • 2011-01-09
    相关资源
    最近更新 更多