I am trying to consume a SOAP web service with PHP.
The web service WSDL can be found here.
Simply creating the client like that:
try {
$wsdlUrl = 'https://eu1.praxedo.com/eTech/services/cxf/v6/BusinessEventManager?WSDL';
$client = new SoapClient($wsdlUrl);
}
catch(Exception $e) {
echo $e->getMessage();
}
This fails with the following error:
SOAP-ERROR: Parsing WSDL: Unknown required WSDL extension ‘http://schemas.xmlsoap.org/ws/2004/09/policy’
I tried using 2 separate generators:
- https://github.com/WsdlToPhp/PackageGenerator
- https://github.com/wsdl2phpgenerator/wsdl2phpgenerator
They both fail with the exact same error.
PHP version is 7.0
I found this old bug report from 2008 which apparently never got fixed because not enough info was submitted at the time.
Does anyone know how I can fix that issue?
2
Answers
Not sure this is available on 7.0 but try setting the option
soap_version
toSOAP_1_2
(see the docs).If you look at your WSDL you will see it imports a WS-Policy section:
See http://specs.xmlsoap.org/ws/2004/09/policy/ws-policy.pdf for details:
It’s probably on this that your code generator chokes, although I don’t know why; these policies apply at execution time. If you have difficulties generating the code because of them, you could remove that import from the WSDL and try to generate the client code without the policies. You basically download the WSDL to a local file, delete that import line above, and feed this modified local WSDL file to your code generators and your SoapClient.
You will still need to respect the policies when calling the SOAP web service (for example, the service requires basic authentication), but the generated client code should be the same with both versions of the WSDL.
As mentioned in the other answer, you also need to use SOAP 1.2 since the binding in the WSDL is defined as SOAP 1.2 (the SOAP Envelope will have this namespace
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
).