Sending Raw XML via PHP SoapClient request

假如想象 提交于 2019-11-29 10:59:42
Fostah

Update/Resolution: Here is the code I used to extend the SOAP Client and send my raw Soap Envelope

Here is how I extended SoapClient:

<?php
class MySoapClient extends SoapClient {

    function __construct($wsdl, $options) {
        parent::__construct($wsdl, $options);
        $this->server = new SoapServer($wsdl, $options);
    }
    public function __doRequest($request, $location, $action, $version) 
    { 
        $result = parent::__doRequest($request, $location, $action, $version); 
        return $result; 
    } 
    function __myDoRequest($array,$op) { 
        $request = $array;
        $location = 'http://xxxxx:xxxx/TransactionServices/TransactionServices6.asmx';
        $action = 'http://www.micros.com/pos/les/TransactionServices/'.$op;
        $version = '1';
        $result =$this->__doRequest($request, $location, $action, $version);
        return $result;
    } 
}

// To invoke my new custom method with my Soap Envelope already prepared.
$soapClient = new MySoapClient("http://xxxx:xxxx/TransactionServices/TransactionServices6.asmx?WSDL", array("trace" => 1)); 
$PostTransaction = $soapClient->__myDoRequest($orderRequest,$op); 
?>

Also posted on pastie.org: http://pastie.org/3687935 before I turned this into the answer.

For testing purposes, you can subclass SoapClient and override the __doRequest method - it receives the generated XML and you can pre-process it.

But better find what's going wrong with the XML encoding. You can use SoapVar and SoapParam instances to specify the exact way given object has to be represented. Those saved my life when namespaces had to be given

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!