Thread

Posted on Tue Mar 4 19:31:11 2008 by eugenio63
What module(s) should i use to throw a soap exception in my server
Hello i'm Eugenio from Argentina and i'm using the SOAP::WSDL 2.0 library to provide web services. I have generated the soap modules without problems with wsdl2perl.pl. In the .cgi that i'm using as server, i have defined one function and i'd like it to throw an exception. So the question is: What module(s) should i use to throw a soap exception, so it can be caught from another application.
# server.cgi use My::SOAP::Server::Foo::FooSoap; my $server = My::SOAP::Server::Foo::FooSoap->new({ dispatch_to => 'main', transport_class => 'SOAP::WSDL::Server::CGI', # optional, default }); $server->handle(); sub register_user { my ($self, $body, $header) = @_; if ( not $foo ) { #throw exception } return Educativa::SOAP::Elements::registrar_usuario_response->new( { usuario => 'Ok' #string }, );
Direct Responses: 7266 | Write a response
Posted on Tue Mar 4 21:07:10 2008 by mkutter in response to 7262
Re: What module(s) should i use to throw a soap exception in my server
Hi Eugenio,

The proper way to throw a exception is just to die - SOAP::WSDL::Server::CGI catches the exception and sends a SOAP Fault back to the client.

If you want more control over the SOAP Fault sent to the client, you can die with a SOAP::WSDL::SOAP::Fault11 object - or just let the SOAP::Server's deserializer create one for you:

my $soap = MyServer::SomeService->new(); die $soap->get_deserializer()->generate_fault({ code => 'soap:Server', role => 'urn:localhost', message =>; "The error message to pas back", detail => "Some details on the error", });

You may use any other object as exception, provided it has a serialize() method which returns the object's XML representation.

Write a response