[Xml-compile] XOP with XML::Compile::WSDL11

Christopher Taranto christopher at tokpela.com
Mon Oct 17 23:55:27 GMT 2016


Hi Kip,

@Hi Mark!

I've been using XOP for a few years in Production with XML::Compile in two
different scripts.

It's been a while since I had to put this together so I don't remember the
particulars.

The below code is not the working code - as it is separated behind objects
etc - but I think I have patched together the general theme:

I hope this helps!

Chris

use XML::Compile::WSDL11;      # use WSDL version 1.1
use XML::Compile::SOAP11;      # use SOAP version 1.1
use XML::Compile::Transport::SOAPHTTP;
use XML::Compile::XOP;

my $xml_compile = XML::Compile::WSDL11->new($primary_wsdl,
		  			    schema_dirs => \@schema_dirs)
  		     || die "[Error] UNABLE TO CREATE XML::Compile::WSDL11 OBJECT";

foreach (@wsdls) {
	$xml_compile->addWSDL($_);
}

foreach (@schemas) {
	$xml_compile->importDefinitions($_);
}

# setup the XML::Compile transport for HTTP with the LWP user_agent
my $ua = LWP::UserAgent->new(keep_alive => 1);

if ($jar_file) {

	$ua->cookie_jar( {file => $jar_file,
			  autosave       => 1,
			  ignore_discard => 1 });

}

my $transport = XML::Compile::Transport::SOAPHTTP->new(user_agent => $ua,
						       soap       => $self->soap_version);

# compile the client call
my $client_call = $xml_compile->compileClient($operation_name,
				  	      port  => $service_port,
					      trans => $transport);

my ($answer, $trace, $xops);

eval {

	($answer, $trace, $xops) = $client_call->(@request_params);

};

if ($@) {

	die "[Error] UNABLE TO COMPLETE REQUEST: [$@] - ANSWER[$answer] -
TRACE[$trace] - XOPS[$xops]";

}


On Mon, Oct 17, 2016 at 4:27 PM, Kit Peters <Kit.Peters at broadbean.com>
wrote:

> I tried that, like so (not actual code):
>
> # $xml_content is <Attributes>…</Attributes><Content>…</Content>
> my $xop = XML::Compile::XOP->new;
> my $content = $xop->bytes( $xml_content, type => ‘text/xml’ );
> # Call to submitLargeDocument has been compiled already
> $wsdl->call( ‘submitLargeDocument’, parameters => { Document => $content }
> );
>
> And when I look at the content just before it’s sent to the server, I
> don’t see that it’s being translated into MTOM. Instead I see:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <soap11:Envelope xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
>   <soap11:Header>
>     <wsa:MessageID xmlns:wsa="http://www.w3.org/2005/03/addressing">Query-
> Export-5490E6F8-94BE-11E6-9A62-DBB52521867A</wsa:MessageID>
>     <wsa:ReplyTo xmlns:wsa="http://www.w3.org/2005/03/addressing">
>       <wsa:Address>http://www.taleo.com/ws/integration/toolkit/
> 2005/07/addressing/queue</wsa:Address>
>     </wsa:ReplyTo>
>     <wsa:Action xmlns:wsa="http://www.w3.org/2005/03/addressing">http://
> www.taleo.com/ws/integration/toolkit/2005/07/action/export</wsa:Action>
>   </soap11:Header>
>   <soap11:Body>
>     <tns0:submitLargeDocument xmlns:tns0="http://www.taleo.
> com/ws/integration/toolkit/2011/05/management" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance">
>       <tns0:Document><!-- # Long base64 string redacted --> tns0:Document>
>     </tns0:submitLargeDocument>
>   </soap11:Body>
> </soap11:Envelope>
>
> I expect this is happening because of the following element in the WSDL:
>
>             <xsd:element name="submitLargeDocument">
>                 <xsd:complexType>
>                     <xsd:sequence>
>                         <xsd:element maxOccurs="1" minOccurs="1"
> name="Document" nillable="true" type="nsm:StreamBody" nsxmlmime:
> expectedContentTypes="application/octet-stream"/>
>                     </xsd:sequence>
>                 </xsd:complexType>
>             </xsd:element>
>
> Am I doing the XOP right, and if so, how do I put this into MTOM, rather
> than just base64 encoding the XML fragment? Do I need to fiddle the WSDL
> somehow?
>
> KP
> --
> Kit Peters
> Doer of Things, ATS Integrations
> D: +1 949 793 8208   M: +1 816 200 0279
>
> On 10/17/16, 04:54, "Mark Overmeer" <mark at overmeer.net> wrote:
>
>     * Kit Peters (Kit.Peters at broadbean.com) [161014 15:33]:
>     > How do I make an XOP request using XML::Compile::WSDL11? I’ve seen
>     > the XOP unit test in XML::Compile::SOAP, but I’m not sure how to
> adapt
>     > that to a compiled call with XML::Compile::WSDL11.
>
>     Produce the XOP Include elements and put them in your data-tree on the
>     usual spot for that data.  During the creation of the SOAP message,
>     it will get attached and replaced by the attachement reference.
>     --
>     greetz,
>                    MarkOv
>
>     ------------------------------------------------------------
> ------------
>            Mark Overmeer MSc                                MARKOV
> Solutions
>            Mark at Overmeer.net
> solutions at overmeer.net
>     http://Mark.Overmeer.net
> http://solutions.overmeer.net
>
>
>
> _______________________________________________
> Xml-compile mailing list
> Xml-compile at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20161017/4074dc72/attachment.htm>


More information about the Xml-compile mailing list