PHP SOAP client that understands multi-part messages?

后端 未结 7 609
死守一世寂寞
死守一世寂寞 2020-12-03 03:27

Is there such a beastie? The simple SOAP client that ships with PHP does not understand multi-part messages. Thanks in advance.

7条回答
  •  猫巷女王i
    2020-12-03 04:13

    Using S. Gehrig second idea worked just fine here.

    In most cases, you have just a single message packed into a MIME MultiPart message. In those cases a "SoapFault exception: [Client] looks like we got no XML document" exception is thrown. Here the following class should do just fine:

    class MySoapClient extends SoapClient
    {
        public function __doRequest($request, $location, $action, $version, $one_way = 0)
        {
            $response = parent::__doRequest($request, $location, $action, $version, $one_way);
            // strip away everything but the xml.
            $response = preg_replace('#^.*(<\?xml.*>)[^>]*$#s', '$1', $response);
            return $response;
        }
    }
    

提交回复
热议问题