|
-
November 18th, 2009, 07:51 PM
#1
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...
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,
-
November 18th, 2009, 09:42 PM
#2
Re: Client catching Web Service User Exceptions [Java 6.0.17]
http://java.sun.com/javaee/5/docs/ap.../WebFault.html
should be used on the exception class you want to be marshalled and information included about in your wsdl otherwise the client won't see it, but it will be wrapped in a general soap exception.
------
If you are satisfied with the responses, add to the user's rep!
-
November 18th, 2009, 11:40 PM
#3
Re: Client catching Web Service User Exceptions [Java 6.0.17]
UserException has @WebFault already - or is it missing something?
I catch the exception, and it is in the WSDL, but it looks like either the String ErrorMessage isn't returning correctly...
-
November 19th, 2009, 11:29 AM
#4
Re: Client catching Web Service User Exceptions [Java 6.0.17]
what version of metro is this?
------
If you are satisfied with the responses, add to the user's rep!
-
November 19th, 2009, 11:54 PM
#5
Re: Client catching Web Service User Exceptions [Java 6.0.17]
What do you mean "Metro"?
-
November 20th, 2009, 10:49 AM
#6
Re: Client catching Web Service User Exceptions [Java 6.0.17]
http://java.sun.com/webservices/
Do you see the soap fault definition in the generated wsdl?
I would expect the definition to look similar to something like this:
Code:
<message name="function">
<part name="fault" element="tns:UserException"/>
</message>
...
<operation name="functionEvent">
<input message="tns:functionResponseEvent"/>
<output message="tns:functionEventResponse"/>
<fault message="tns:UserException" name="UserException"/>
</operation>
...
<fault name="UserException">
<soap:fault name="UserException" use="literal"/>
</fault>
Last edited by Deliverance; November 20th, 2009 at 10:59 AM.
------
If you are satisfied with the responses, add to the user's rep!
-
November 21st, 2009, 07:34 PM
#7
Re: Client catching Web Service User Exceptions [Java 6.0.17]
Yes I see something similar, the difference is the custom GetMessage() function is not in the WSDL.
Actually - it looks like using the super (Message) solved the problem ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|