Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Client catching Web Service User Exceptions [Java 6.0.17]

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    [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
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Client catching Web Service User Exceptions [Java 6.0.17]

    Do you really need to use the WebFault annotation?

    // Json

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Client catching Web Service User Exceptions [Java 6.0.17]

    Not sure - I am pretty much trying anything/everything to get my exception to work.
    Removing it doesn't help ...

Similar Threads

  1. RMI over SSL Client application
    By boilerchicken in forum Java Networking
    Replies: 0
    Last Post: November 10th, 2009, 07:52 AM
  2. ha-jndi client is servlet
    By supriya ramjee in forum Web Frameworks
    Replies: 0
    Last Post: July 31st, 2009, 02:02 AM
  3. [SOLVED] web client
    By 5723 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: June 10th, 2009, 04:44 PM
  4. Free java hosting service providers
    By servlet in forum Java Servlet
    Replies: 1
    Last Post: May 14th, 2009, 07:28 AM
  5. How to write switch statement inside if statement?
    By Rezz in forum Loops & Control Statements
    Replies: 6
    Last Post: June 11th, 2008, 11:27 AM