Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

soap webservices - return error message?

I have a little soap webservice. And I wonder how I can response with errors.

Eg:

public int createUser(String username) {
   //create...
   return id;
}

Now, if the user could not be created, how do I make a proper response? Do I have to throw a custom exception? Which is the right way?

like image 822
membersound Avatar asked May 02 '26 22:05

membersound


2 Answers

The correct approach here is to translate the exception into a SOAP Fault.

like image 111
Reimeus Avatar answered May 05 '26 13:05

Reimeus


I do this in my SOAP server - but don't fool around with trying to build your own Soap fault - simply throw a runtime exception and that should get converted into a soap fault.

like image 40
lightswitch05 Avatar answered May 05 '26 13:05

lightswitch05