Results 1 to 5 of 5
  1. #1
    Shaitan00 is offline Member
    Join Date
    Nov 2009
    Posts
    3
    Rep Power
    0

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

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,805
    Rep Power
    19

    Default

    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.

  3. #3
    Shaitan00 is offline Member
    Join Date
    Nov 2009
    Posts
    3
    Rep Power
    0

    Default

    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"

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,805
    Rep Power
    19

    Default

    What does the exception look like in a debugger at the client?

  5. #5
    Shaitan00 is offline Member
    Join Date
    Nov 2009
    Posts
    3
    Rep Power
    0

    Default

    Actually - it looks like using the super (Message) solved the problem ...

Similar Threads

  1. catching uncaught exceptions using Spring / WebApp
    By taille50 in forum Web Frameworks
    Replies: 1
    Last Post: 10-18-2009, 01:14 AM
  2. Web service client
    By Tshegofatsom in forum New To Java
    Replies: 1
    Last Post: 09-09-2009, 02:31 PM
  3. Consume a .net web service with a java client
    By pauldj54 in forum New To Java
    Replies: 3
    Last Post: 07-15-2009, 11:53 AM
  4. java.lang.OutOfMemoryError in a web service client
    By elchape in forum Advanced Java
    Replies: 4
    Last Post: 06-28-2008, 05:21 PM
  5. TCPIP Client (handling specific exceptions)
    By ravian in forum Networking
    Replies: 3
    Last Post: 11-29-2007, 09:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •