I am attempting to interface a Java based SOAP server with a SOAP::Lite client. The two can communicate but sadly there seems to be an XML processing problem at the Java end:
javax.xml.soap.SOAPException: Unable to create envelope from given sou
+rce: Error on line 1 of document : Undeclared prefix: "SOAP-ENV:enco
+dingStyle"
The server, in this case, simply returns a default response back to the Perl client which is being decoded properly so thats not a problem.
From what I can tell, the processor does not like all the namespaces (and such) that get added to the Envelope by the SOAP::Lite call. Though this is valid XML is there anyway I can either:
- remove these by hand before transmitting to the server
- dynamically build the envelope as a string (or something similar) and transmit that?
I've been scouring the groups I could find but haven't found anything that comes close to this problem.
Source code for the client follows (I call as perl soap.pl). Note that I am not using RPC at this time but just whacking a mini XML document into the Body of the message.
If I'm committing any other sins then please let me know as I've only been using SOAP::Lite for a very short time.
use SOAP::Lite;
use Data::Dumper;
use strict;
use warnings;
my $data = <<EOL;
<ar>
<site url="127.0.0.1" />
<request id="2" type="text" command="AdvertByID" />
</ar>
EOL
my $service = new SOAP::Lite
uri => 'http://test/',
proxy => 'http://simonp.intranet-dev:8080/servlet/middleware',
soapversion => 1.2,
xmlschema => '2001'
;
my $fragment = SOAP::Data->type(xml => $data);
my $serializer = $service->serializer();
my $env = $serializer->envelope(freeform => $fragment);
my $response = $service->call($env);
my $body = $response->dataof('//Body/ar/al/ai'); # should give acces
+s to body
my $attr = $body->attr();
print "Type: ", $attr->{'type'},"\n";
print "ID: ", $attr->{'id'},"\n";
my $summary = $response->dataof('//Body/ar/al/ai/summary');
$attr = $summary->attr();
print "Summary: ", $attr->{'data'},"\n";
my $title = $response->dataof('//Body/ar/al/ai/title');
$attr = $title->attr();
print "Title: ", $attr->{'data'},"\n";
my $anchor = $response->dataof('//Body/ar/al/ai/anchor');
$attr = $anchor->attr();
print "Link: ", $attr->{'data'},"\n";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.