Results 1 to 5 of 5
- 11-18-2009, 06:22 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
Client catching Web Service User Exceptions [Java 6.0.17]
I am trying to send an EXCEPTION from a Web Server to a Client using JAX-WS ...
When the exception is thrown by the server the client does catch it ... but the contents are not the expected message...
Java Code:[Server.java] package pck; @WebService() public class Server { @WebMethod() public function() throws UserException { throw new UserException(“Something”); } } [Exception.java] import javax.xml.ws.WebFault; @WebFault() public class UserException extends Exception { private String ErrMessage; public UserException(String message) { this.ErrMessage = message; } public String ErrorMessage() { return this.ErrMessage; } } [Client.java] public class Client { public static void main(String[] args) throws Exception { try { Server.function(); } catch (UserException ex) { System.out.println("User Exception: " + ex.ErrorMessage()); } } }
Now, as I mentioned, when the exception is thrown by the server the client does catch it, but ex.ErrorMessage() returns the string “pck.UserException” instead of “Something” which it was created with in the Server... any clues as to why?
Also, when I run my WebService I keep getting the following messages in the output:
com.sun.xml.internal.ws.model.RuntimeModeler getExceptionBeanClass
INFO: Dynamically creating exception bean Class pck.jaxws.UserExceptionBean
Any clues or help would be much appreciated.
Thanks,
- 11-19-2009, 09:26 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Print the stack trace and see what it is you're looking at? I never rely on the error message, since you lose far too much information that way.
It does seem odd, though, that it would alter the content of the exception. What does the WSDL look like? Specifically the bit that defines this wsdl:fault? That might give you a pointer to how JAX-WS has chosen to define the exception.
- 11-20-2009, 05:33 AM #3
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
The WSDL has a wsdl:fault for my exception, but no mention anywhere of the String ErrMessage ... I would have assumed it would be there ... but no matter what I try the WSDL never seems to "pick it up"
- 11-20-2009, 07:58 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
What does the exception look like in a debugger at the client?
- 11-22-2009, 01:09 AM #5
Member
- Join Date
- Nov 2009
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
catching uncaught exceptions using Spring / WebApp
By taille50 in forum Web FrameworksReplies: 1Last Post: 10-18-2009, 01:14 AM -
Web service client
By Tshegofatsom in forum New To JavaReplies: 1Last Post: 09-09-2009, 02:31 PM -
Consume a .net web service with a java client
By pauldj54 in forum New To JavaReplies: 3Last Post: 07-15-2009, 11:53 AM -
java.lang.OutOfMemoryError in a web service client
By elchape in forum Advanced JavaReplies: 4Last Post: 06-28-2008, 05:21 PM -
TCPIP Client (handling specific exceptions)
By ravian in forum NetworkingReplies: 3Last Post: 11-29-2007, 09:56 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks