XML::Compile::WSDL11 - accessing the transport layer
Mark Overmeer
mark at overmeer.net
Fri Apr 11 09:37:17 BST 2008
* Toby Corkindale (tjc at wintrmute.net) [080411 05:02]:
> On Fri, Apr 11, 2008 at 12:08:39PM +1000, Toby Corkindale wrote:
> > I'm using XML::Compile::WSDL11 to generate some SOAP services, but I
> > want to get access to the LWP::UserAgent object..
> >
> > Can anyone help me with the missing step here?
>
> I never did figure out the right way to get to the transport layer, and
> eventually decided that X-C-T-SOAPHTTP just didn't export the package-wide
> %transporters hash via any means.
>
> I created a work-around, see below if you ever need to do this yourself:
>
> > my $wsdl = slurp('service.wsdl');
> > my $service = XML::Compile::WSDL11->new($wsdl);
You can also do:
my $service = XML::Compile::WSDL11->new('service.wsdl');
> my $transport = XML::Compile::Transport::SOAPHTTP->new(
> address => $server_uri
> );
The problem is that a WSDL can declare multiple protocols, which may
not be support by one transport implementation, like LWP. For instance,
I already got sucj report about XMPP (Jabber)... not supported by LWP,
but used in WSDL.
So, there cannot be a $service->userAgent method, even though there
may be a global variable which contains it...
> my $ua = $transport->userAgent;
> # Hurrah, now set all your custom LWP::UserAgent options.
> # ...
>
> my $call = $service->compileClient('MyService',
> port => 'MyPort',
> transport => $transport,
> );
The only way to get your hands on the LWP::UserAgent used for one or
more WSDL operations, is by avoiding the auto-generated internal
objects, but specify them explicitly. So, you approach is sane.
You could also do:
my $ua = LWP::UserAgent->new; # get it somewhere, SSL setup>
my $transporter = XML::Compile::Transport::SOAPHTTP->new(user_agent => $ua);
my $http = $transporter->compileClient(soap => 'SOAP11', ...);
my $call = $wsdl->compileClient('myport', transport => $http);
$call->($data);
You can leave-out steps 1, 2, and/or 3 in various combinations, to still
get something working. Each step has its own responsibilities, so may
require configuration. This traject is not documented as a whole yet.
> I welcome any suggestions on easier ways to perform this..
Gladly, you can reuse the objects in all above steps, so probably it
is not too much of a burdon on the whole program when you need to
configure this communication layers in special ways.
--
Regards,
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark at Overmeer.net solutions at overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net
More information about the london.pm
mailing list