dongpu5600 2018-11-08 19:57
浏览 78
已采纳

PHP - 如何在SoapClient中设置页脚

With PHP, I need to send a SOAP request with a parameter (Hash) in the footer. I'm using SoapClient but I can not figure out how to do this, neither in internet searches, nor in documentation.

This is the envelope I used in the SoapUI tool to test:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:abc="" xmlns:abc1="" xmlns:abc2="">
   <soapenv:Header/>
   <soapenv:Body>
      <abc:Method>
         <!--Optional:-->
         <abc:request>
            <abc1:Header>
               <abc1:Username>Username</abc1:Username>
               <abc1:Password>Password</abc1:Password>
               <!--Optional:-->
               <abc1:PublicKeyUid></abc1:PublicKeyUid>
            </abc1:Header>
            <abc1:Body>
               <abc2:Id></abc2:Id>
            </abc1:Body>
            <abc1:Footer>
                <abc1:Hash></abc1:Hash>
            </abc1:Footer>
         </abc:request>
      </abc:Method>
   </soapenv:Body>
</soapenv:Envelope>

There is The SoapHeader class e the SoapClient::__setSoapHeaders method but I find nothing related to the footer.

I do not have access to the server and should follow this structure mentioned above.

What I need to know is how to send the HASH parameter that is inside the footer with SoapClient.

Thanks in advance for any help or suggestion.

  • 写回答

1条回答 默认 最新

  • dongyi5070 2018-12-09 14:48
    关注

    As IMSoP and axiac have commented, the footer (<abc1: Footer>) is just a sub-structure of the envelop body and not a standard XML envelop element. I had not realized this and so I did not find it in the documentation.

    So to send HASH to the requested structure, I need to pass a multidimensional array on the body element. The code looks like this:

    $arrParameters = [
        'request'=>[
            'Header'=>[
                'Username'=>$strUsername,
                'Password'=>$strPassword
            ],
            'Body'=>[
                ...
            ],
            'Footer'=>[
                'Hash'=>$strHash
            ]
        ]
    ];
    
    $SoapClient = new SoapClient(<WSDL URL>);
    
    $resp = $SoapClient->method($arrParameters);
    


    Thank you IMSoP and axiac!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀