8

It is many questions there about PHP and SOAP. But I am not found answer on my situation.

So. I use PHP SoapClient and WSDL for it. Object sends this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.site.com"><SOAP-ENV:Body>

But I need this:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body>

Question. How I can do this with standard PHP class SoapClient?

Thank you.

3
  • I think that means your WSDL is incorrect? Did you create the SOAP server piece also?
    – Clutch
    Mar 16, 2010 at 18:25
  • No, WSDL is correct, because other library (ActiveX control for C#) works with it good and send true namespace. I can't change SOAP-server. I need use it to access to service functions.
    – Oleg
    Mar 17, 2010 at 10:09
  • If you think this is causing an issue in communicating with your SOAP service, this may be an incorrect assumption. Your error may be related to missing properties in your message, as has just happened to me.
    – bytespider
    Feb 20, 2014 at 11:37

2 Answers 2

5

I search answer in php.net

<?php
class MSSoapClient extends SoapClient {

    function __doRequest($request, $location, $action, $version) {
        $namespace = "http://tempuri.com";

        $request = preg_replace('/<ns1:(\w+)/', '<$1 xmlns="'.$namespace.'"', $request, 1);
        $request = preg_replace('/<ns1:(\w+)/', '<$1', $request);
        $request = str_replace(array('/ns1:', 'xmlns:ns1="'.$namespace.'"'), array('/', ''), $request);

        // parent call
        return parent::__doRequest($request, $location, $action, $version);
    }
}

$client = new MSSoapClient(...);
?>

This code change Envelope in request. And need for ASP SOAP server.

0

Use SoapVar::typeNamespace for set your xmlns:xsi

something like this :

new SoapVar($data, SOAP_ENC_OBJECT, "Type", "http://www.w3.org/2001/XMLSchema");

source : https://www.php.net/manual/fr/soapvar.construct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.