[Xml-compile] WS-Security to Axis2 server
David McMath
mcdave at stanford.edu
Thu Aug 30 05:25:22 GMT 2012
On 8/28/12 6:45 PM, gstewart wrote:
> Ok, so I'm slowly limping along from one problem to the next :-)
>
> My application interface is running on an Axis2 server with
> rampart installed. All the examples I've googled to date are for Java,
> access. I want to do it in Perl.
>
> From various sources I've cobbled together an attempt to send the wsse
> headers, as part of the query:
>
Not that I completely understand your situation, but it seems like the
wsp:Policy element is just saying that you're going to need
UsernameToken with the requests. XML::Compile::WSDL11 isn't going to
figure that out on its own, so you're needing to put the wsse:Security
section containing a wsse:UsernameToken element into the header
yourself. So that's the example you were using. Fine.
I think you should be able to do that with
XML::Compile::SOAP::WSS#wsseBasicAuth like you were trying before in the
other thread.
But this case got me interested, so I did some poking. I kept cribbing
from XML::Compile::WSS until it ran. Since the error message was
"cannot find element or attribute", I just told the $wsdl where to find
it with
>
> my $wsdl = XML::Compile::WSDL11->new($wsdl_data->content);
> $wsdl->importDefinitions($schema_data->content);
>
$wsdl->importDefinitions(
'/Library/Perl/5.10.0/XML/Compile/WSS/wss11/200401-wss-secext.xsd' ) ;
$wsdl->importDefinitions(
'/Library/Perl/5.10.0/XML/Compile/WSS/wss11/200401-wss-utility.xsd' ) ;
Certainly not best practice, but it made the errors go away. That made
it so I could run your script down to
> my $UsernameToken_element = pack_type WSS_SECEXT_200401,
> 'UsernameToken';
> my $UsernameToken_writer =
> $wsdl->schemas->compile(WRITER => $UsernameToken_element);
Where it threw the error
panic: schemas() removed in v2.00, not needed anymore
at /Library/Perl/5.10.0/XML/Compile/WSDL11.pm line 65
which says "old example" to me. But change that to
my $UsernameToken_writer =
$wsdl->compile(WRITER => $UsernameToken_element);
and it keeps running to the end, until
> my ($result, $trace) = $call->(
> header => { $UsernameToken_element => $UsernameToken_value },
> # rest of arguments
> );
Which said
mistake: tag `header' not used at
{http://endace.com/ninjaprobe/}VersionQuery
at /Library/Perl/5.10.0/XML/Compile/Translate/Writer.pm line 548
and I can't really disagree. That's just a warning. There's something
somewhere about calling "addHeader" on something to make that piece work
(XML::Compile::SOAP::WSS does that), but I don't really know how that works.
dave
More information about the Xml-compile
mailing list