ptum has asked for the wisdom of the Perl Monks concerning the following question:
I'm pretty new to SOAP. I've been using SOAP::Lite to generate SOAP messages for a vendor-provided service inside our corporate firewall. For messages with simple types, I've gotten it to work, although it has involved a lot of trial and error before I got the XML formatted the way the service was expecting it.
Now I'm running into trouble generating a SOAP message with a complex type (basically an array of min and max integer values which represent ranges of numbers). The fault codes I'm getting back when my message fails are pretty useless: soap:Server in the fault code, a bunch of useless (to me, anyway) java error messages in the stacktrace, and a 500 internal server error in the SOAP::Transport response. I asked the vendor to write their service so it can accept whatever and respond in a more helpful manner (telling me if my XML was malformed, specifically showing which element had problems, etc.). They respond:
"The arguments which are passed from the SOAP client are first decoded before reaching the application. The format and data types need to match what is expected in the wdsl file."
Is there a way for me to prevalidate my XML against the WSDL? I see (or interpret, anyway) that SOAP::Lite doesn't support WSDLs with complex types ... is there another way to skin this cat? It seems like a cop-out for the vendor to defer all error handling to the WSDL if there is no way for me to verify my XML against the WSDL ... or am I misunderstanding the purpose of the WSDL?
Just for context, I'm creating my SOAP connection in this manner (I've left out some of the proprietary stuff), and executing the 'add' method as follows:
sub build_SOAP_connection { my $self = shift; my $ns = $self->{'data'}->{'namespace'}; my $ep = $self->{'data'}->{'proxy'}; my $lite = SOAP::Lite->uri($ns)->proxy($ep)->on_action( sub { join " +", @_ } ); $lite->autotype(0); $lite->soapversion('1.1'); $lite->serializer()->namespaces({ 'http://schemas.xmlsoap.org/soap/envelope/' => 'soap', 'http://schemas.xmlsoap.org/soap/envelope/' => 'soapenv', 'http://schemas.xmlsoap.org/soap/encoding/' => 'soapenc', 'http://www.w3.org/2001/XMLSchema' => 'xsd', 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi' }); $self->{'SOAP'} = $lite; return $lite; } sub SOAP_execute { my $self = shift; my $method = shift; my $datagram = shift; my $SOAP; if (exists($self->{'SOAP'})) { $SOAP = $self->{'SOAP'}; } else { $SOAP = $self->build_SOAP_connection(); } my $doc = SOAP::Data->name($method)->uri($self->{'data'}->{'namespac +e'})->prefix(''); my $response; eval { $response = $SOAP->call($doc => $datagram); }; if ($@) { print "Error: $method SOAP call died: $@.\n"; return 1; } if ($response->fault) { print "Fault code: ", $response->faultcode, "\n"; print "Fault string: ", $response->faultstring, "\n"; print "Fault actor: ", $response->faultactor, "\n"; return $response->faultcode; } else { my $body = $response->result; # returns the first object unless ($body == 0) { $self->{'data'}->{'ERROR'} = "ERROR: method $method failed: $bod +y"; } return $body; } }
Should I push back to the vendor and require them to respond with decent error messages if my XML is badly formed or typed, or is their position reasonable and I simply need to figure out how to validate my own messages? Advice on validating my XML against the WSDL is particularly welcome.
2006-04-08 Retitled by planetscape, as per Monastery guidelines
Original title: 'OT: Validating SOAP with a WSDL'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Validating SOAP with a WSDL
by idsfa (Vicar) on Apr 06, 2006 at 18:32 UTC | |
by ptum (Priest) on Apr 07, 2006 at 14:02 UTC | |
by john_oshea (Priest) on Apr 07, 2006 at 14:25 UTC | |
|
Re: Validating SOAP with a WSDL
by jhourcle (Prior) on Apr 06, 2006 at 18:53 UTC |