SOAP-ERROR: Parsing WSDL: Unknown required WSDL extension 'http://schemas.xmlsoap.org/ws/2004/09/policy' in PHP SoapClient while calling SAP PI

后端 未结 4 1883
小鲜肉
小鲜肉 2020-12-28 09:00

I\'m trying to implement a Web Service running on an SAP PI system. The WSDL I got looks like this:




        
相关标签:
4条回答
  • 2020-12-28 09:58

    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).

    0 讨论(0)
  • 2020-12-28 09:59

    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"/>
    
    0 讨论(0)
  • 2020-12-28 10:01

    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.

    0 讨论(0)
  • 2020-12-28 10:02

    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

    0 讨论(0)
提交回复
热议问题