users@jax-rpc.java.net

Re: Can interfaces thrown exceptions? (Other than RemoteException ?)

From: Arun Gupta <arun.gupta_at_Sun.COM>
Date: Fri, 12 Apr 2002 12:00:27 -0700

Hi Michael,

Please refer to JAX-RPC release notes with EA2 at
http://java.sun.com/webservices/docs/ea2/jaxrpc/ReleaseNotes.html.

Service specific exceptions must have only one public constructor that
has one argument. The type of this constructor must match at least one
method which has a name that starts with get, takes no arguments, and
returns the same type as the constructor. For example:


public class MyException extends Exception {

    private MyType type;

    public MyException(MyType type) {
        this.type = type;
    }

    public MyType getType() {
        return type;
    }
}

This limitation will be relaxed in the future.

Thanks for your interest in JAX-RPC.

Regards,
-Arun


YAWN,MICHAEL (HP-Cupertino,ex1) wrote:

>Thanks for the pointers. I have this working now, but I'm
>still a little confused as to why the changes were required.
>If someone from the JAX-RPC team can comment on the exact
>requirements for Exceptions, I'd appreciate it: I'm writing
>these examples for a book, and I'd like to make the description
>as accurate as possible.
>
>An Exception or Throwable object would seem to meet the
>requirements for a JavaBean; it's only state is the 'message',
>and there is a public getMessage() call.
>
>In order to make my exception work, I needed to create a
>local (subclass) variable to store the state, and a public
>getter method for it. I pass to the exception constructor
>a string called 'name'; it is stored in local 'name'
>variable accessible via getName(). I'm just not clear
>why this subclass variable works, but the getMessage()
>inherited from Throwable as not sufficient.
>
>Anyway, it's working now; so I'm just looking for any
>clarifications that can help me write it up more accurately.
>
>Thanks!
>Mike
>
>>-----Original Message-----
>>From: Hrishikesh Bhagwat [mailto:Hrishikesh.Bhagwat_at_XORIANT.COM]
>>Sent: Thursday, April 11, 2002 10:15 PM
>>To: JAXRPC-INTEREST_at_JAVA.SUN.COM
>>Subject: Re: Can interfaces thrown exceptions? (Other than
>>RemoteException ?)
>>
>>
>>I did make changes to my applications and made it throw
>>a subclass of java.lang.Exception. I got the same problem as
>>the one you have reported.
>>
>>Then i extended that class from RemoteException and still continued
>>to get the same error !
>>
>>However when i added a getMessage() method to the sub class, xrpcc
>>started to function correctly immaterial of the fact whether i was
>>extending the class from Exception or RemoteException.
>>
>> refer to 6.4.4 (sub section : "Encoded Fault")
>> of the JAX RPC specifications(version 0.6).
>> (I could not find this section in version 0.8 !!!)
>>
>>
>>The reason for this "may be" that .... "by default, JAX-RPC
>>can only serialize classes (other than those specified
>>in the standard JAVA-XML type mapping)which are of type
>>JAVA Beans. Such serializers marshall these Beans type classes
>>(classes with getters and setter) into XML-complexTypes".
>>May be the same applies to Exceptions (Exception classes).
>>However this explaination may not be correct for i havent
>>yet really studied the Exceptions related part in the specs.
>>
>>
>>Hrishikesh
>>
>>
>>
>>
>>
>>
>>-----Original Message-----
>>From: YAWN,MICHAEL (HP-Cupertino,ex1) [mailto:mike_yawn_at_HP.COM]
>>Sent: Thursday, April 11, 2002 10:09 PM
>>To: JAXRPC-INTEREST_at_JAVA.SUN.COM
>>Subject: Re: Can interfaces thrown exceptions? (Other than
>>RemoteException ?)
>>
>>
>>OK, that makes sense. I'll avoid RuntimeException subclasses.
>>
>>But I get the same error if I just add Exception to my method
>>signatures -- xrpcc reports 'java.lang.Exception not supported'.
>>
>>Any ideas? I've been working with the EA1 release, but just
>>updated to EA2 to see if it would help with this and other
>>problems I'm having. Doesn't seem to affect this one (haven't
>>yet tried the others).
>>
>>Mike
>>
>>
>>>-----Original Message-----
>>>From: Hrishikesh Bhagwat [mailto:Hrishikesh.Bhagwat_at_XORIANT.COM]
>>>Sent: Wednesday, April 10, 2002 9:05 PM
>>>To: JAXRPC-INTEREST_at_JAVA.SUN.COM
>>>Subject: Re: Can interfaces thrown exceptions? (Other than
>>>RemoteException ?)
>>>
>>>
>>>Hi Mike,
>>>
>>>Refer the following lines from JAX-RPC 0.8 spec (Section 5.2.1)
>>>
>>>"A service specific exception declared in a remote method
>>>signature must be
>>>a checked
>>>exception. It must extend java.lang.Exception either directly
>>>or indirectly
>>>but must
>>>not be a RuntimeException."
>>>
>>>
>>>IllegalArgumentException extends from a RuntimeException.
>>>Thats your problem
>>>
>>>Hrishikesh
>>>
>>>
>>>-----Original Message-----
>>>From: YAWN,MICHAEL (HP-Cupertino,ex1) [mailto:mike_yawn_at_HP.COM]
>>>Sent: Wednesday, April 10, 2002 10:39 PM
>>>To: JAXRPC-INTEREST_at_JAVA.SUN.COM
>>>Subject: Can interfaces thrown exceptions? (Other than
>>>RemoteException?)
>>>
>>>
>>>I thought that JAX-RPC interfaces could throw exceptions other than
>>>RemoteException, and that these exceptions would be mapped to SOAP
>>>Faults. But if I add a 'throws IllegalArgumentException' to
>>>my interface,
>>>xrpcc balks saying that the exception isn't supported.
>>>
>>>Section 14.3.6 shows some mappings between SOAP faults and
>>>Java exceptions. Are these the only legal exceptions that an RPC
>>>service can throw? If I want to indicate an illegal argument was
>>>passed, how to I create a RemoteException that is mapped onto
>>>the rpc:BadArguments SOAP fault, since RemoteException also
>>>maps onto rpc:ProcedureNotPresent? (Or should I even care
>>>how it gets mapped -- will the client see any difference between
>>>the two?)
>>>
>>>Mike
>>>

--
=============================================
There is only one me, I must live myself!
There is only one today, I must live itself!
=============================================
http://members.tripod.com/~apgupta/index.html
=============================================