You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Michael Merz <mm...@bea.com> on 2004/12/14 19:12:20 UTC

Question on user exception handling on autogenerated clients

Bcc: beehive-dev@incubator.apache.org

I'm autogenerating my clients using the wsdl2java ant task. It's working
really well.

One question regarding exception handling, though: When the server
throws a custom exception (subclass of java.lang.Exception), how does
the autogenerated client propagate the results in the response to the
caller? I had a look at the generated code and couldn't find any hooks
(see below). Is this not yet implemented? Thanks much.

Cheers,

-michael

    public int throwFooException(int in0) throws
java.rmi.RemoteException,
org.apache.beehive.wsm.test.rpclit.FooException {
        if (super.cachedEndpoint == null) {
            throw new org.apache.axis.NoEndPointException();
        }
        org.apache.axis.client.Call _call = createCall();
        _call.setOperation(_operations[0]);
        _call.setUseSOAPAction(true);
        _call.setSOAPActionURI("");
        _call.setEncodingStyle(null);
        _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
Boolean.FALSE);
        _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
Boolean.FALSE);
 
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS
);
        _call.setOperationName(new
javax.xml.namespace.QName("http://rpclit.test.wsm.beehive.apache.org",
"throwFooException"));

        setRequestHeaders(_call);
        setAttachments(_call);
        java.lang.Object _resp = _call.invoke(new java.lang.Object[]
{new java.lang.Integer(in0)});

        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException)_resp;
        }
        else {
            extractAttachments(_call);
            try {
                return ((java.lang.Integer) _resp).intValue();
            } catch (java.lang.Exception _exception) {
                return ((java.lang.Integer)
org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
            }
        }
    }


Re: Question on user exception handling on autogenerated clients

Posted by Davanum Srinivas <da...@gmail.com>.
pls check the test/wsdl/faults example.

-- dims


On Tue, 14 Dec 2004 10:12:20 -0800, Michael Merz <mm...@bea.com> wrote:
> Bcc: beehive-dev@incubator.apache.org
> 
> I'm autogenerating my clients using the wsdl2java ant task. It's working
> really well.
> 
> One question regarding exception handling, though: When the server
> throws a custom exception (subclass of java.lang.Exception), how does
> the autogenerated client propagate the results in the response to the
> caller? I had a look at the generated code and couldn't find any hooks
> (see below). Is this not yet implemented? Thanks much.
> 
> Cheers,
> 
> -michael
> 
>     public int throwFooException(int in0) throws
> java.rmi.RemoteException,
> org.apache.beehive.wsm.test.rpclit.FooException {
>         if (super.cachedEndpoint == null) {
>             throw new org.apache.axis.NoEndPointException();
>         }
>         org.apache.axis.client.Call _call = createCall();
>         _call.setOperation(_operations[0]);
>         _call.setUseSOAPAction(true);
>         _call.setSOAPActionURI("");
>         _call.setEncodingStyle(null);
>         _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
> Boolean.FALSE);
>         _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
> Boolean.FALSE);
> 
> _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS
> );
>         _call.setOperationName(new
> javax.xml.namespace.QName("http://rpclit.test.wsm.beehive.apache.org",
> "throwFooException"));
> 
>         setRequestHeaders(_call);
>         setAttachments(_call);
>         java.lang.Object _resp = _call.invoke(new java.lang.Object[]
> {new java.lang.Integer(in0)});
> 
>         if (_resp instanceof java.rmi.RemoteException) {
>             throw (java.rmi.RemoteException)_resp;
>         }
>         else {
>             extractAttachments(_call);
>             try {
>                 return ((java.lang.Integer) _resp).intValue();
>             } catch (java.lang.Exception _exception) {
>                 return ((java.lang.Integer)
> org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
>             }
>         }
>     }
> 
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

Re: Question on user exception handling on autogenerated clients

Posted by Davanum Srinivas <da...@gmail.com>.
pls check the test/wsdl/faults example.

-- dims


On Tue, 14 Dec 2004 10:12:20 -0800, Michael Merz <mm...@bea.com> wrote:
> Bcc: beehive-dev@incubator.apache.org
> 
> I'm autogenerating my clients using the wsdl2java ant task. It's working
> really well.
> 
> One question regarding exception handling, though: When the server
> throws a custom exception (subclass of java.lang.Exception), how does
> the autogenerated client propagate the results in the response to the
> caller? I had a look at the generated code and couldn't find any hooks
> (see below). Is this not yet implemented? Thanks much.
> 
> Cheers,
> 
> -michael
> 
>     public int throwFooException(int in0) throws
> java.rmi.RemoteException,
> org.apache.beehive.wsm.test.rpclit.FooException {
>         if (super.cachedEndpoint == null) {
>             throw new org.apache.axis.NoEndPointException();
>         }
>         org.apache.axis.client.Call _call = createCall();
>         _call.setOperation(_operations[0]);
>         _call.setUseSOAPAction(true);
>         _call.setSOAPActionURI("");
>         _call.setEncodingStyle(null);
>         _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
> Boolean.FALSE);
>         _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
> Boolean.FALSE);
> 
> _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS
> );
>         _call.setOperationName(new
> javax.xml.namespace.QName("http://rpclit.test.wsm.beehive.apache.org",
> "throwFooException"));
> 
>         setRequestHeaders(_call);
>         setAttachments(_call);
>         java.lang.Object _resp = _call.invoke(new java.lang.Object[]
> {new java.lang.Integer(in0)});
> 
>         if (_resp instanceof java.rmi.RemoteException) {
>             throw (java.rmi.RemoteException)_resp;
>         }
>         else {
>             extractAttachments(_call);
>             try {
>                 return ((java.lang.Integer) _resp).intValue();
>             } catch (java.lang.Exception _exception) {
>                 return ((java.lang.Integer)
> org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
>             }
>         }
>     }
> 
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

Re: Question on user exception handling on autogenerated clients

Posted by TMG <tm...@nc.rr.com>.
Michael,

The server services throw a RemoteException, that's what you "catch" in 
the client.  If a handler, either before or after the service is called, 
throws an exception, it is usually an AxisFault.

Tom Gordon

Michael Merz wrote:

>Bcc: beehive-dev@incubator.apache.org
>
>I'm autogenerating my clients using the wsdl2java ant task. It's working
>really well.
>
>One question regarding exception handling, though: When the server
>throws a custom exception (subclass of java.lang.Exception), how does
>the autogenerated client propagate the results in the response to the
>caller? I had a look at the generated code and couldn't find any hooks
>(see below). Is this not yet implemented? Thanks much.
>
>Cheers,
>
>-michael
>
>    public int throwFooException(int in0) throws
>java.rmi.RemoteException,
>org.apache.beehive.wsm.test.rpclit.FooException {
>        if (super.cachedEndpoint == null) {
>            throw new org.apache.axis.NoEndPointException();
>        }
>        org.apache.axis.client.Call _call = createCall();
>        _call.setOperation(_operations[0]);
>        _call.setUseSOAPAction(true);
>        _call.setSOAPActionURI("");
>        _call.setEncodingStyle(null);
>        _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
>Boolean.FALSE);
>        _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
>Boolean.FALSE);
> 
>_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS
>);
>        _call.setOperationName(new
>javax.xml.namespace.QName("http://rpclit.test.wsm.beehive.apache.org",
>"throwFooException"));
>
>        setRequestHeaders(_call);
>        setAttachments(_call);
>        java.lang.Object _resp = _call.invoke(new java.lang.Object[]
>{new java.lang.Integer(in0)});
>
>        if (_resp instanceof java.rmi.RemoteException) {
>            throw (java.rmi.RemoteException)_resp;
>        }
>        else {
>            extractAttachments(_call);
>            try {
>                return ((java.lang.Integer) _resp).intValue();
>            } catch (java.lang.Exception _exception) {
>                return ((java.lang.Integer)
>org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
>            }
>        }
>    }
>
>
>  
>


RE: Question on user exception handling on autogenerated clients

Posted by Choi Jongjin <gu...@hotmail.com>.
Hi, Michael.

Handling service-specific exception is implemented in Axis. 

In the generated code, 

>         java.lang.Object _resp = _call.invoke(new java.lang.Object[]
>{new java.lang.Integer(in0)});
>
>         if (_resp instanceof java.rmi.RemoteException) {
>             throw (java.rmi.RemoteException)_resp;
>         }
>         else {

AFAIK, _call.invoke() returns RemoteException (AxisFault) for propagated 
soap fault (server-side exception).

But Axis's implementation lacks of JAX-RPC 1.1 compatibility.
The generated exception classes are derived classes of AxisFault and 
require default constructor and setters which are not required in JAX-RPC 
1.1.

I guess this causes some problem.
If you use JAX-RPC 1.1 compliant exception classes (which have not default 
constructor 
and setter methods) in the client side, the deserialization of SOAP Fault 
message would fail.

I will add other comments in JIRA BEEHIVE-133.

/Jongjin
 

>From: "Michael Merz" <mm...@bea.com>
>Reply-To: "Beehive Developers" <be...@incubator.apache.org>
>To: <ax...@ws.apache.org>
>CC: <di...@apache.org>
>Subject: Question on user exception handling on autogenerated clients
>Date: Tue, 14 Dec 2004 10:12:20 -0800
>
>Bcc: beehive-dev@incubator.apache.org
>
>I'm autogenerating my clients using the wsdl2java ant task. It's working
>really well.
>
>One question regarding exception handling, though: When the server
>throws a custom exception (subclass of java.lang.Exception), how does
>the autogenerated client propagate the results in the response to the
>caller? I had a look at the generated code and couldn't find any hooks
>(see below). Is this not yet implemented? Thanks much.
>
>Cheers,
>
>-michael
>
>     public int throwFooException(int in0) throws
>java.rmi.RemoteException,
>org.apache.beehive.wsm.test.rpclit.FooException {
>         if (super.cachedEndpoint == null) {
>             throw new org.apache.axis.NoEndPointException();
>         }
>         org.apache.axis.client.Call _call = createCall();
>         _call.setOperation(_operations[0]);
>         _call.setUseSOAPAction(true);
>         _call.setSOAPActionURI("");
>         _call.setEncodingStyle(null);
>         _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,
>Boolean.FALSE);
>         _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,
>Boolean.FALSE);
>
>_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS
>);
>         _call.setOperationName(new
>javax.xml.namespace.QName("http://rpclit.test.wsm.beehive.apache.org",
>"throwFooException"));
>
>         setRequestHeaders(_call);
>         setAttachments(_call);
>         java.lang.Object _resp = _call.invoke(new java.lang.Object[]
>{new java.lang.Integer(in0)});
>
>         if (_resp instanceof java.rmi.RemoteException) {
>             throw (java.rmi.RemoteException)_resp;
>         }
>         else {
>             extractAttachments(_call);
>             try {
>                 return ((java.lang.Integer) _resp).intValue();
>             } catch (java.lang.Exception _exception) {
>                 return ((java.lang.Integer)
>org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
>             }
>         }
>     }
>