TheFluffyOne has asked for the wisdom of the Perl Monks concerning the following question:
I'm currently playing around with accessing a WSDL service (RealOps AMP/BMC RBA for those interested) using SOAP::Lite and need to craft a request in the right format.
I managed to find an old post that almost did what I needed and munged the code into the following:
#!/usr/bin/perl -w use strict; use SOAP::Lite +trace => 'debug', maptype => { }; my $userId = "admin"; my $password = "adminpw"; my $wsdl = "http://10.50.50.132:9080/ws/workflow"; my $gridName = SOAP::Header->name("grid-name" => SOAP::Data->type('' = +> 'SampleGrid1')); my $rba = SOAP::Lite->uri('urn:realops.com:amp:workflow')->proxy($wsdl +); my $wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-ws +security-secext-1.0.xsd"; my $securityHeader = SOAP::Header->name( Security => { UsernameToken => { Username => SOAP::Data->type('' => $userId)->prefix('wsse' +), Password => SOAP::Data->type('' => $password)->prefix('wss +e'), } })->uri($wsse)->prefix('wsse'); my $result = $rba->getAllSOAPServices($gridName, $securityHeader)
This code results in a soap header as follows:
<soap:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/ +oasis-200401-wss-wssecurity-secext-1.0.xsd"> <UsernameToken> <wsse:Password>adminpw</wsse:Password> <wsse:Username>admin</wsse:Username> </UsernameToken> </wsse:Security> <grid-name>SampleGrid1</grid-name> </soap:Header>
The header needs to look like this:
<soapenv:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/ +oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>admin</wsse:Username> <wsse:Password>adminpw</wsse:Password> </wsse:UsernameToken> </wsse:Security> <grid-name xmlns="urn:realops.com:amp:workflow">SampleGrid1</grid- +name> </soapenv:Header>
How can I get the "wsse" prefix on the UsernameToken tag? I also need to add the xmlns attribute to grid-name, but I haven't finished RTFMing on that one yet...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Setting XML prefix for tags with SOAP::Lite
by AltBlue (Chaplain) on Jul 31, 2008 at 00:53 UTC | |
by TheFluffyOne (Beadle) on Jul 31, 2008 at 05:45 UTC | |
by TheFluffyOne (Beadle) on Jul 31, 2008 at 21:20 UTC | |
by TheFluffyOne (Beadle) on Jul 31, 2008 at 21:56 UTC | |
by TheFluffyOne (Beadle) on Aug 01, 2008 at 09:34 UTC |