drn34916 2018-07-16 06:10
浏览 1115
已采纳

使用soapenv的SOAP请求

I have the following code for connecting to a soap client. I am struggling hard to find how to create a proper soap request.

$soap = new SoapClient($apiWsdl,
        array("soap_version" => SOAP_1_1,
              "trace" => 1));
var_dump($soap);
echo $soap->__getLastResponse();
try{
    $data = $soap->login($apiUser,$apiKey);
}
catch (SoapFault $soapFault) {
    echo "Request :<br>", htmlentities($soap->__getLastRequest()), "<br>";
    echo "Response :<br>", htmlentities($soap->__getLastResponse()), "<br>";

}

I get the following XML built:

<?xml version="1.0" encoding="UTF-8"?> \<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:login><username xsi:type="xsd:string">XXXXXXX</username><apiKey xsi:type="xsd:string">XXXXXXXX</apiKey></ns1:login></SOAP-ENV:Body></SOAP-ENV:Envelope> 


Which returns be a forbidden access.

However the server is accepting only request of the following form



<soapenv:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:urn="urn:Magento">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <username xsi:type="xsd:string">XXXXXXX</username>
         <apiKey xsi:type="xsd:string">XXXXXX</apiKey>
      </urn:login>
   </soapenv:Body>
</soapenv:Envelope>

Can somebody please let me know what mistake I am making in the code.

  • 写回答

1条回答 默认 最新

  • doutu9810 2018-07-16 06:29
    关注

    It looks like you have a typo right after the XML tags. There is a backslash that should not be there. This could trigger your errors.

    HTH, Jim

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

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料