简体   繁体   中英

PHP: Default SOAP XML Namespace

I'm using PHP 5.6 as that is what the client is using. I have to communicate with a Microsoft WCF Service via SOAP without using WSDL.

I'm more or less there, however it would make my life a lot easier if there was a way to set the default XML namespace for the SOAP envelope.

I thought setting the 'URI' option on the SoapClient constructor would do this but it hasn't.

The WCF service sets this default namespace, so without it, I have to explicitly mark up all the SoapVar variables with that namespace in order for it to work.

Is it possible to get the SoapClient to set the default namespace?

ie

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns="http://tempuri.org/">
<!-- SOAP Contents -->
</soap:Envelope>

Default Namespace being http://tempuri.org/ .

If you're asking that then you're probably using WSDL mode. The WSDL defines the default namespace.

Otherwise the docs help you:

If working in non-WSDL mode, the location and uri options must be set, where location is the URL of the SOAP server to send the request to, and uri is the target namespace of the SOAP service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM