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

使用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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失