Shaitan00 -1 Light Poster

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...

[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,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.