I\'m trying to implement a Web Service running on an SAP PI system. The WSDL I got looks like this:
This isn't really the correct answer in a SAP environment. In your URL for the WSDL, you'll see /ws_policy/
- change this to /standard/
and you'll be able to use the PHP SoapClient class to consume the web service without having to maintain a local modified copy of the WSDL. You can see the same on a SAP blog here (login probably required).
The only solution I can think of at this point is to update your UsingPolicy tag:
Change the tag:
<wsp:UsingPolicy wsdl:required="true"/>
to this:
<wsp:UsingPolicy wsdl:required="false"/>
Seems to be a bug in PHP SOAPServer, or a missing extension compatibility, and it hasn't been solved yet, at least in PHP 5.6.31.
The only solution I could find was to set required UsingPolicy
to false
, as suggested in the accepted response:
<wsp:UsingPolicy wsdl:required="false" />
But clients could access the SOAP service without authentication, which is a serious security issue. So, I tried to manually check that the security data is sent by the client.
$soapEnvelope = new DOMDocument();
$soapEnvelope->loadXML(file_get_contents("php://input"), LIBXML_DTDATTR);
$wsseNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
if ($soapEnvelope->getElementsByTagNameNS($wsseNamespace, 'Security')->length == 0) {
throw new SoapFault("auth", 'Authentication error - Missing wsse:Security node');
}
if ($soapEnvelope->getElementsByTagNameNS($wsseNamespace, 'UsernameToken')->length == 0) {
throw new SoapFault("auth", 'Authentication error - Missing UsernameToken node');
}
if ($soapEnvelope->getElementsByTagNameNS($wsseNamespace, 'Username')->length == 0) {
throw new SoapFault("auth", 'Authentication error - Missing Username node');
}
if ($soapEnvelope->getElementsByTagNameNS($wsseNamespace, 'Password')->length == 0) {
throw new SoapFault("auth", 'Authentication error - Missing Password node');
}
// SOAPServer handle requests method
$server->handle();
It's a dirt trick, but it works.
For new versions the URL is not containing anymore the "ws_policy" instead there is a 0 (standard)or 1 (policy)
Example:
....wsdl/flv_10002A111AD1/bndg_url/.... (ws_policy)
....wsdl/flv_10002A101AD1/bndg_url/.... (standard)
Credits to Rafa Martinez