• <bdo id='VpZi6'></bdo><ul id='VpZi6'></ul>

        <small id='VpZi6'></small><noframes id='VpZi6'>

        <legend id='VpZi6'><style id='VpZi6'><dir id='VpZi6'><q id='VpZi6'></q></dir></style></legend>

      1. <i id='VpZi6'><tr id='VpZi6'><dt id='VpZi6'><q id='VpZi6'><span id='VpZi6'><b id='VpZi6'><form id='VpZi6'><ins id='VpZi6'></ins><ul id='VpZi6'></ul><sub id='VpZi6'></sub></form><legend id='VpZi6'></legend><bdo id='VpZi6'><pre id='VpZi6'><center id='VpZi6'></center></pre></bdo></b><th id='VpZi6'></th></span></q></dt></tr></i><div id='VpZi6'><tfoot id='VpZi6'></tfoot><dl id='VpZi6'><fieldset id='VpZi6'></fieldset></dl></div>
      2. <tfoot id='VpZi6'></tfoot>

        PHP &amp;XML - 如何从此 XML 在 PHP 中生成soap请求

        时间:2023-05-22
          <bdo id='6x8pB'></bdo><ul id='6x8pB'></ul>
            <tbody id='6x8pB'></tbody>
          <legend id='6x8pB'><style id='6x8pB'><dir id='6x8pB'><q id='6x8pB'></q></dir></style></legend>
        • <small id='6x8pB'></small><noframes id='6x8pB'>

          <i id='6x8pB'><tr id='6x8pB'><dt id='6x8pB'><q id='6x8pB'><span id='6x8pB'><b id='6x8pB'><form id='6x8pB'><ins id='6x8pB'></ins><ul id='6x8pB'></ul><sub id='6x8pB'></sub></form><legend id='6x8pB'></legend><bdo id='6x8pB'><pre id='6x8pB'><center id='6x8pB'></center></pre></bdo></b><th id='6x8pB'></th></span></q></dt></tr></i><div id='6x8pB'><tfoot id='6x8pB'></tfoot><dl id='6x8pB'><fieldset id='6x8pB'></fieldset></dl></div>

            <tfoot id='6x8pB'></tfoot>

                  本文介绍了PHP &amp;XML - 如何从此 XML 在 PHP 中生成soap请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我对 SOAP 操作完全陌生.

                  I am completly new to SOAP operations.

                  我收到了一个 XML 文档 (SOAP),以获取一些运输方式的收集点.

                  I have been provided with an XML document (SOAP) to get some collection points for a shipping method.

                  来自此处的手册:

                  http://privpakservices.schenker.nu/package/package_1.3/packageservices.asmx?op=SearchCollectionPoint

                  我可以看到我需要使用以下 SOAP 请求:

                  I can see that I need to use the following SOAP request:

                  POST /package/package_1.3/packageservices.asmx HTTP/1.1
                  Host: privpakservices.schenker.nu
                  Content-Type: text/xml; charset=utf-8
                  Content-Length: length
                  SOAPAction: "http://privpakservices.schenker.nu/SearchCollectionPoint"
                  
                  <?xml version="1.0" encoding="utf-8"?>
                  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                    <soap:Body>
                      <SearchCollectionPoint xmlns="http://privpakservices.schenker.nu/">
                        <customerID>long</customerID>
                        <key>string</key>
                        <serviceID>string</serviceID>
                        <paramID>int</paramID>
                        <address>string</address>
                        <postcode>string</postcode>
                        <city>string</city>
                        <maxhits>int</maxhits>
                      </SearchCollectionPoint>
                    </soap:Body>
                  </soap:Envelope>
                  

                  问题是我不知道如何使用 PHP 将其作为请求发送,以及如何获得响应.

                  The thing is that i don't know how to send this as a request using PHP, and how to get the response.

                  任何帮助我确定正确方向的帮助,非常感谢.

                  Any help to pinpoint me in the right direction, is much appreciated.

                  更新

                  我可以用 var_dump 读取响应数据.但是,我无法读取单个元素数据.

                  I can read the response data with var_dump. However, I am not able to read individual element data.

                  我需要读取如下数据

                  foreach($parser as $row) {
                    echo $row->customerID;
                    echo $row->key;
                    echo $row->serviceID;  
                  }
                  

                  推荐答案

                  如果有人感兴趣,我已经提供了正确答案:

                  If anyone should be interested, i have provided the correct answer:

                  $soapUrl = "http://privpakservices.schenker.nu/package/package_1.3/packageservices.asmx?op=SearchCollectionPoint";
                  
                  $xml_post_string = '<?xml version="1.0" encoding="utf-8"?><soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body><SearchCollectionPoint xmlns="http://privpakservices.schenker.nu/"><customerID>XXX</customerID><key>XXXXXX-XXXXXX</key><serviceID></serviceID><paramID>0</paramID><address>RiksvŠgen 5</address><postcode>59018</postcode><city>Mantorp</city><maxhits>10</maxhits></SearchCollectionPoint></soap12:Body></soap12:Envelope>';
                  
                  $headers = array(
                  "POST /package/package_1.3/packageservices.asmx HTTP/1.1",
                  "Host: privpakservices.schenker.nu",
                  "Content-Type: application/soap+xml; charset=utf-8",
                  "Content-Length: ".strlen($xml_post_string)
                  ); 
                  
                  $url = $soapUrl;
                  
                  $ch = curl_init();
                  curl_setopt($ch, CURLOPT_URL, $url);
                  curl_setopt($ch, CURLOPT_POST, true);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                  
                  $response = curl_exec($ch); 
                  curl_close($ch);
                  
                  $response1 = str_replace("<soap:Body>","",$response);
                  $response2 = str_replace("</soap:Body>","",$response1);
                  
                  $parser = simplexml_load_string($response2);
                  

                  这篇关于PHP &amp;XML - 如何从此 XML 在 PHP 中生成soap请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:SoapFault 异常:[HTTP] 获取 http 标头时出错 下一篇:SOAP-ERROR:编码:违反编码规则?

                  相关文章

                  最新文章

                    <bdo id='hYST4'></bdo><ul id='hYST4'></ul>
                  <i id='hYST4'><tr id='hYST4'><dt id='hYST4'><q id='hYST4'><span id='hYST4'><b id='hYST4'><form id='hYST4'><ins id='hYST4'></ins><ul id='hYST4'></ul><sub id='hYST4'></sub></form><legend id='hYST4'></legend><bdo id='hYST4'><pre id='hYST4'><center id='hYST4'></center></pre></bdo></b><th id='hYST4'></th></span></q></dt></tr></i><div id='hYST4'><tfoot id='hYST4'></tfoot><dl id='hYST4'><fieldset id='hYST4'></fieldset></dl></div>

                  <legend id='hYST4'><style id='hYST4'><dir id='hYST4'><q id='hYST4'></q></dir></style></legend>
                  1. <tfoot id='hYST4'></tfoot>

                    1. <small id='hYST4'></small><noframes id='hYST4'>