The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
=head1 NAME

XML::Compile::Transport::SOAPHTTP - exchange XML-SOAP via HTTP

=head1 INHERITANCE

 XML::Compile::Transport::SOAPHTTP
   is a XML::Compile::Transport
   is a XML::Compile::SOAP::Extension

=head1 SYNOPSIS

 use XML::Compile::Transport::SOAPHTTP;

 my $http = XML::Compile::Transport::SOAPHTTP->new(@options);
 my $send = $http->compileClient(@options2);

 my $call = $wsdl->compileClient
   ( operation => 'some-port-name'
   , transport => $send
   );

 my ($xmlout, $trace) = $call->($xmlin);

=head1 DESCRIPTION

This module handles the exchange of (XML) messages, according to the
rules of SOAP (any version).  The module does not known how to parse
or compose XML, but only worries about the HTTP aspects.

=head1 METHODS

=head2 Constructors

=over 4

=item XML::Compile::Transport::SOAPHTTP-E<gt>B<new>(OPTIONS)

The C<keep_alive> and C<timeout> options are used when an LWP::UserAgent
is created, and ignored when you provide such an object.  In the latter
case, the values for those are inquired such that you can see the setting
directly from the passed object.

If you need to change UserAgent settings later, you can always directly
access the LWP::UserAgent object via L<userAgent()|XML::Compile::Transport::SOAPHTTP/"Accessors">.

 -Option    --Defined in             --Default
  address     XML::Compile::Transport  'http://localhost'
  charset     XML::Compile::Transport  'utf-8'
  keep_alive                           <true>
  timeout                              180
  user_agent                           <created when needed>

=over 2

=item address => URI|ARRAY-of-URI

=item charset => STRING

=item keep_alive => BOOLEAN

When connection can be re-used.

=item timeout => SECONDS

The maximum time for a single connection before the client will close it.
The server may close it earlier.  Do not set the timeout too long, because
you want objects to be cleaned-up.

=item user_agent => LWP::UserAgent object

If you pass your own user agent, you will be able to configure
it. Otherwise, one will be created with all the defaults. Providing
your own user agents -or at least have a look at the configuration-
seems like a good idea.

=back

=back

=head2 WSDL11

=over 4

=item $obj-E<gt>B<wsdl11Init>(WSDL, ARGS)

=item XML::Compile::Transport::SOAPHTTP-E<gt>B<wsdl11Init>(WSDL, ARGS)

See L<XML::Compile::SOAP::Extension/"WSDL11">

=back

=head2 SOAP11

=over 4

=item $obj-E<gt>B<soap11ClientWrapper>(OPERATION, CALL, ARGS)

See L<XML::Compile::SOAP::Extension/"SOAP11">

=item $obj-E<gt>B<soap11HandlerWrapper>(OPERATION, CALLBACK, ARGS)

See L<XML::Compile::SOAP::Extension/"SOAP11">

=item $obj-E<gt>B<soap11OperationInit>(OPERATION, ARGS)

=item XML::Compile::Transport::SOAPHTTP-E<gt>B<soap11OperationInit>(OPERATION, ARGS)

See L<XML::Compile::SOAP::Extension/"SOAP11">

=back

=head2 Accessors

=over 4

=item $obj-E<gt>B<address>()

See L<XML::Compile::Transport/"Accessors">

=item $obj-E<gt>B<addresses>()

See L<XML::Compile::Transport/"Accessors">

=item $obj-E<gt>B<charset>()

See L<XML::Compile::Transport/"Accessors">

=item $obj-E<gt>B<userAgent>([AGENT|(undef, OPTIONS)])

Returns the User Agent which will be used.  You may change the
configuration of the AGENT (the returned LWP::UserAgent object)
or provide one yourself.  See also L<new(user_agent)|XML::Compile::Transport::SOAPHTTP/"METHODS">.

Changes to the agent configuration can be made before or after the
compilation, or even inbetween SOAP calls.

=back

=head2 Handlers

=over 4

=item $obj-E<gt>B<compileClient>(OPTIONS)

Compile an HTTP client handler.  Returned is a subroutine which is called
with a text represenation of the XML request, or an XML::LibXML tree.
In SCALAR context, an XML::LibXML parsed tree of the answer message
is returned.  In LIST context, that answer is followed by a HASH which
contains trace information.

 -Option    --Defined in             --Default
  action                               ''
  header                               <created>
  hook        XML::Compile::Transport  <undef>
  kind                                 'request-response'
  method                               'POST'
  mime_type                            <depends on soap version>
  mpost_id                             42
  soap                                 'SOAP11'
  xml_format  XML::Compile::Transport  0

=over 2

=item action => URI

=item header => HTTP::Headers object

Versions of L<XML::Compile|XML::Compile>, L<XML::Compile::SOAP|XML::Compile::SOAP>, and LWP will be
added to simplify bug reports.

=item hook => CODE

=item kind => DIRECTION

What kind of interactie, based on the four types defined by WSDL(1):
C<notification-operation> (server initiated, no answer required),
C<one-way> (client initiated, no answer required), C<request-response>
(client initiated, the usual in both directions), C<solicit-response> (server
initiated "challenge").

=item method => 'POST'|'M-POST'

With C<POST>, you get the standard HTTP exchange.  The C<M-POST> is
implements the (Microsoft) HTTP Extension Framework.  Some servers
accept both, other require a specific request.

=item mime_type => STRING

=item mpost_id => INTEGER

With method C<M-POST>, the header extension fields require (any) number
to be grouped.

=item soap => 'SOAP11'|'SOAP12'|OBJECT

=item xml_format => 0|1|2

=back

example: create a client

 my $trans = XML::Compile::Transport::SOAPHTTP->new
   ( address => 'http://www.stockquoteserver.com/StockQuote'
   );

 my $call = $trans->compileClient
   ( action  => 'http://example.com/GetLastTradePrice'
   );

 # $request and $answer are XML::LibXML trees!
 # see XML::Compile::SOAP::Client::compileClient() for wrapper which
 # converts from and to Perl data structures.

 my ($answer, $trace) = $call->($request);
 my $answer = $call->($request); # drop $trace info immediately

=item $obj-E<gt>B<headerAddVersions>(HEADER)

=item XML::Compile::Transport::SOAPHTTP-E<gt>B<headerAddVersions>(HEADER)

Adds some lines about module versions, which may help debugging
or error reports.  This is called when a new client or server
is being created.

=back

=head1 Helpers

=over 4

=item XML::Compile::Transport::SOAPHTTP-E<gt>B<register>(URI)

See L<XML::Compile::Transport/"Helpers">

=back

=head1 SEE ALSO

This module is part of XML-Compile-SOAP distribution version 2.35,
built on January 14, 2013. Website: F<http://perl.overmeer.net/xml-compile/>

Other distributions in this suite:
L<XML::Compile>,
L<XML::Compile::SOAP>,
L<XML::Compile::SOAP12>,
L<XML::Compile::SOAP::Daemon>,
L<XML::Compile::SOAP::WSA>,
L<XML::Compile::C14N>,
L<XML::Compile::WSS>,
L<XML::Compile::WSS::Signature>,
L<XML::Compile::Tester>,
L<XML::Compile::Cache>,
L<XML::Compile::Dumper>,
L<XML::Compile::RPC>,
L<XML::Rewrite>,
L<XML::eXistDB>,
and
L<XML::LibXML::Simple>.

Please post questions or ideas to the mailinglist at
F<http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile>

For live contact with other developers, visit the C<#xml-compile> channel
on C<irc.perl.org>.

=head1 LICENSE

Copyrights 2007-2013 by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>