SOAP将参数添加到XML的标头部分

时间:2018-09-06 18:05:18

标签: php xml soap

我试图使用php和SoapClient发布到SOAP服务。我可以从SoapUI获取请求以使其正常工作,但是当我从SoapUI复制xml请求并将其放入php中的SoapVars方法时,我总是收到从服务器返回的错误。基本上它说我缺少Username参数(即使在那里)

所以,我想知道的是如何使用当前使用SoapVar和XML字符串的实现来解决此问题。.但是,如果这不可能,那么我欢迎您提出建议。

这是xml请求

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
xmlns:rgw="http://rgwspublic2/RgWsPublic2Service" xmlns:rgw1="http://rgwspublic2/RgWsPublic2">
<env:Header>
  <ns1:Security>
       <ns1:UsernameToken>
           <ns1:Username>******</ns1:Username>
           <ns1:Password>******</ns1:Password>
     </ns1:UsernameToken>
  </ns1:Security>
   </env:Header>
  <env:Body>
  <ns2:rgWsPublic2AfmMethod>
     <ns2:INPUT_REC>
        <ns3:afm_called_by/>
        <ns3:afm_called_for>******</ns3:afm_called_for>
     </ns2:INPUT_REC>
  </ns2:rgWsPublic2AfmMethod>
 </env:Body>

另外,这是我正在使用的代码-

$client = new SoapClient("https://www1.gsis.gr:443/wsaade/RgWsPublic2/RgWsPublic2?WSDL", array("soap_version"=> SOAP_1_2,"trace" => true, "exceptions" =>
1));


$params = new SoapVar('<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:rgw="http://rgwspublic2/RgWsPublic2Service" xmlns:rgw1="http://rgwspublic2/RgWsPublic2">

(加上上面的XML已插入SoapVar中)

0 个答案:

没有答案