Skip to content
Advertisement

Wrong namespaces assigned by PHP SOAP Client

I have little to no experience in SOAP. And I am interacting with a third party wsdl web service. For this I use PHP’s native SoapClient.

When I send the request I’m getting an error response that states the following:

JavaScript

The relevant parts of the autogenerated XML are as follow:

JavaScript

If I take the autogenerated XML, change the namespace alias for the List and Item nodes from ns3 to ns1, and send it through postman, it works like a charm.

I think the problem is that both the ns1 namespace and ns2 namespace have a specification for a ScheduleP, List and Item. and the PHP SoapClient is assigning the wrong namespace alias to the List and Item nodes.

Just for clarification, this is the XML that works:

JavaScript

I have no idea on how to proceed, how can one fix this miss-assignation of namespaces?

Advertisement

Answer

Found a solution. Since I have a class that extends PHP’s SoapClient, I can override the __doRequest() function which receives the generated XML String as its first parameter, then you can apply any modification to that string and finally call parent::__doRequest() to send it.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement