Perl SOAP MTOM/XOP client
"JONES, ROBERT E CTR USAF AETC TTMS/TTMS" <[email protected]> Thu, 20 Oct 2011 13:49:59 -0500
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <2E69B12F0EF78E4395724555B03337ACE13550BFF1@52VEJX-MV08-01.AREA52.AFNOAPPS.USAF.MIL> |
Trying to get this off the ground still. I see the XOP creation and I've got the SOAP constructed, but I'm not able to get the XOP into the SOAP correctly. Unfortunately a clear online example has not been found yet. The output should look like the example below. The program further below is functional, but without the key binary data being transmitted. POST http://some.location.here/web.svc HTTP/1.1 Connection: close Accept-Encoding: gzip,deflate SOAPAction: "methodtouse" Content-Type: multipart/related; type="application/xop+xml"; start="<[email protected]>"; start-info="text/xml"; boundary="----=_Part_30_15497377.1317742780546" MIME-Version: 1.0 User-Agent: Jakarta Commons-HttpClient/3.1 Host: localhost:32033 Connection: Keep-Alive Content-Length: 2104 ------=_Part_30_15497377.1317742780546 Content-Type: application/xop+xml; charset=UTF-8; type="text/xml" Content-Transfer-Encoding: 8bit Content-ID: <[email protected]> <soap:Envelope xmlns:urn2="urn2:namespace2" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:urn="urn:namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:urn1="urn1:namespace1"> <soapenv:Body> <urn1:methodname ID="ALIDID123" EID="123456789" NN="Site-Location" UR="content1"> <urn2:supplement> <urn2:binary> <inc:Include href="cid:123456789" xmlns:inc="http://www.w3.org/2004/08/xop/include"/> </urn2:binary> </urn2:supplement> </urn1:methodname> </soapenv:Body> </soapenv:Envelope> ------=_Part_30_15497377.1317742780546 Content-Type: application/octet-stream Content-Transfer-Encoding: binary Content-ID: <123456789> Content-Disposition: attachment; name="logo.jpg" --bunch of binary stuff here-- ------=_Part_30_15497377.1317742780546-- CODING use SOAP::Lite +debug; use SOAP::Lite on_fault => sub { my ($client, $res) = @_; die ref $res ? $res->faultstring : $client->transport->status, "\n"; }; use XML::Compile; use XML::Compile::XOP; $proxy = 'http://some.location.here/web.svc'; $uri = 'http://tempuri.org/'; ## Build the attachment ## $filename = 'logo.jpg'; $xop = XML::Compile::XOP->new; $data = {image => $xop->bytes($filename)}; ## Define the SOAP client connection ## $client = SOAP::Lite ->readable(1) ->autotype(0) ->uri($uri) ->proxy($proxy); $client->ns('urn:namespace','urn'); $client->ns('urn1:namespace1','urn1'); $client->ns('urn2:namespace2','urn2'); ## Create the SOAP Body ## $inc = SOAP::Data->name('inc:Include') ->attr({'href' => "cid:$cid", 'xmlns:inc' => 'http://www.w3.org/2004/08/xop/include'}); $binary = SOAP::Data->name('binary') ->prefix('urn2') ->value(\SOAP::Data->value($inc)); $suppl = SOAP::Data->name('supplement') ->prefix('urn2') ->value(\SOAP::Data->value($binary)); $top = SOAP::Data->name('CTJS') ->prefix('urn1') ->attr({'ID' => 'ALIDID123', 'EID' => '123456789', 'NN' => 'Site-Location', 'UR' => 'content1'}); ## Pass data to the web service ## $client->on_action(sub { sprintf 'methodtouse' }); $method = 'methodname'; $response = $client->call($top => SOAP::Data->value($suppl)); Robert Jones, BSP, BSCS Keesler AFB _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs