Sending secure wse headers via Soap in php5

I have a problem sending wse security headers for using web services and there are already dozens of ways to use this web service from TargetProcess.com, and I'm not sure what I'm doing wrong.

(http://demo.tpondemand.com/Services/ProjectService.asmx?wsdl)

Their example uses a really old version of Nusoap, however I am trying to do this using php5 built into the SoapClient class.

I am stuck between erroneous request errors or Authentication failed. So how can I send these headers?

This is what I have so far but not working:

     $tp_header_part = '
      <wsa:Action>
        http://targetprocess.com/RetrieveAll
      </wsa:Action>
      <wsa:MessageID>
        urn:uuid:'.$this->getGuid().'
      </wsa:MessageID>
      <wsa:ReplyTo>
        <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
      </wsa:ReplyTo>
      <wsa:To>http://medios.tpondemand.com/Services/ProjectService.asmx</wsa:To>
      <wsse:Security SOAP-ENV:mustUnderstand="1">
        <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
          wsu:Id="SecurityToken-'.$this->getGuid().'">
        <wsse:Username>MYUSERNAME</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
          MYPASSWORD
        </wsse:Password>
        </wsse:UsernameToken>
      </wsse:Security>';


$soap_var_header = new SoapVar( $tp_header_part, XSD_ANYXML, null, null, null );

$soap_header = new SoapHeader( 'http://schemas.xmlsoap.org/ws/2003/06/secext', 'Security', $soap_var_header );
$client->__setSoapHeaders($soap_header);

ps The getGuid function simply generated a manual that matched their documentation.

Any ideas?

+3
source share
1

.NET/ASP, "" XML- - , XML .

XML (wsa, wsse, SOAP-ENV), , , , , PHP SoapClient . , , , , - "wsse" = "http://schemas.xmlsoap.org/ws/2003/06/secext", SoapHeader.

, ( Fiddler2) PHP , , , - , XML .

2 , " XML":

  • wsa: - xmlns:wsa="<URL for definition of WSA>"
  • SoapHeader - , URI , , :

    $soap_header = new SoapHeader( 'http://schemas.xmlsoap.org/ws/2003/06/secext', 'wsse:Security', $soap_var_header );
    

, , HTTP- PHP- - , 100% !

+1

Source: https://habr.com/ru/post/1791707/


All Articles