duanchi19820419 2019-02-18 10:48
浏览 132

如何在PHP SOAP客户端中设置头内的参数

I'm trying to make SOAP petitions where there must be an Addressing parameter declared inside the Header.

Here's my code in PHP:

    $params = array(); 
    $params['xmlns:tem'] = "http://tempuri.org/";
    $params['soap_version'] = SOAP_1_2;
    $params['trace'] = 1;

    $client = new SoapClient("myurl",$params);
    $header = array();
    $header[] = new SoapHeader('http://www.w3.org/2005/08/addressing', "Action", "myurlAction");
    $header[] = new SoapHeader('http://www.w3.org/2005/08/addressing', "To", "myurlTo");
    $client->__setSoapHeaders($header);
    $result = $client->myCall()

To get the results, I have to declare the wsa inside the header like this (notice the ns2 parameter declared in Header):

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/">
    <env:Header xmlns:ns2="http://www.w3.org/2005/08/addressing">
  .... 
</env:Header>

The avobe XML returns the data, so it's what I want the php to generate.

But with my PHP code I get this result (the parameter ns2 is declared in the Envelope instead):

<env:Envelope
xmlns:env="http://www.w3.org/2003/05/soap-envelope"
xmlns:ns1="http://tempuri.org/"
xmlns:ns2="http://www.w3.org/2005/08/addressing">
    <env:Header> ... </env:Header>

How can I achieve this?

Thank you...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程