PHP & XML - How to generate a soap request in PHP from this XML?

前端 未结 2 1311
旧时难觅i
旧时难觅i 2020-12-31 23:46

I am completly new to SOAP operations.

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

From the manual

2条回答
  •  孤城傲影
    2021-01-01 00:06

    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 = 'XXXXXXXXX-XXXXXX0
    RiksvŠgen 5
    59018Mantorp10
    '; $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("","",$response); $response2 = str_replace("","",$response1); $parser = simplexml_load_string($response2);

提交回复
热议问题