Menu

Injecting header

Help
2009-01-16
2013-05-01
  • Glenn Franxman

    Glenn Franxman - 2009-01-16

    I'm trying to use this package with some of Yahoo's soap apis, and they use a number of soap headers to control authentication and authorization.

    The example code tends to involve pretty low level soap interactions. For example, from their perl example code:

    sub make_headers {

        return ( SOAP::Header->name( 'Security' )
                             ->value(
                     \SOAP::Header->name( 'UsernameToken' )
                                  ->value( [ SOAP::Header->name('Username')
                                                         ->value( EWS_USERNAME )
                                                         ->prefix('wsse')
                                             ,
                                             SOAP::Header->name('Password')
                                                         ->value( EWS_PASSWORD )
                                                         ->prefix('wsse')
                                             ,
                                           ]
                                  )
                                  ->prefix( 'wsse' )
                              )
                              ->prefix( 'wsse' )
                              ->uri( 'http://schemas.xmlsoap.org/ws/2002/04/secext' )
                 ,
                 SOAP::Header->name('license')
                             ->value( EWS_LICENSE)
                             ->uri( EWS_NAMESPACE )
                             ->prefix('')
                 ,
                 SOAP::Header->name('accountID')
                             ->type('long')
                             ->value( $ACCOUNT_ID )
                             ->uri( EWS_NAMESPACE )
                             ->prefix('')
                 ,
               );
    }

        my $som = $soap_client->call( $operation => @soap_params, make_headers() );

    I was hoping there might be a way to inject this data either into the proxy object returned by wsdl.getProxy() or include the extra headers in the calls for the operations.

    Any guidance or suggestions would be most appreciated.

     
    • gweis

      gweis - 2009-01-17

      Hi,

      Currently you can pass SOAP Headers just as any other method parameter. If you pass positional parameters, then the headers are the first parameters, else you can just pass them as named parameters.

      There is slight problem with this approach. If there are headers, which have the same name as body parameters, then the proxy can not distinguish between them. So far I had no problems with this issue, but I will address this in one of the future releases.

      As far as I know, there is currently no WS-Security module available for rslib. However, it may be possible to generate the wsse-header contents by yourself. If you can direct me to the WSDL-file for the service, I can provide you with more detailed information about this.

      Cheers,

      Gerhard

       
      • Glenn Franxman

        Glenn Franxman - 2009-01-20

        So, this will result in license and Security header being injected into the call ( assuming the wsdl defines a getOrdersByAccountID method that takes accountID, startRow and maxResults)?

        proxysoap = wsdl.getProxy(NS_SOAP)
        _, ret = proxysoap.getOrdersByAccountID( license="???", Security="??", accountID='???',  startRow=0, maxResults=10 )

         
    • gweis

      gweis - 2009-01-22

      The value for the Security parameter should be something like this:

      {'UserNameToken': {'Username': 'uname', 'Password': 'pw'}}

      Passing custom classes/objects will be supported after the redesign of the rsl.xsd package is finished. Currently, the easiest way to pass complex parameters is, to use python dicts and lists.

      Unfortunately, the current rsl.xsd package has some problems with the xml-schema of this yahoo services (if I got the right WSDL). It does not fully support the xsd:simpleType tag. Hence, the license and accountID parameters can not be serialized.

      I'll fix rsl.xsd this weekend and publish a new release.

      cheers

      Gerhard

       
    • gweis

      gweis - 2009-01-27

      Hi,

      ok, I fixed the simpleType problem in rsl.xsd 0.2.3.
      In principle the yahoo service should work now as described in my previous post. 

      However, the schema definition included in the wsdl of the Yahoo OrderService is a bit strange. It defines the wsse schema with elementFormDefault='unqualified'. So all child elements of the wsse-header are unqualified. This is not intended by the wsse-specification, but I hope Yahoo can deal with this.

      cheers

      Gerhard

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.