users@jax-rpc.java.net

Re: How in the client receive the MyException

From: Phil Goodwin <Phil.Goodwin_at_Sun.COM>
Date: Fri, 11 Oct 2002 08:20:17 -0700

Unfortunately the behavior that you are looking for is not supported in
the current version of JAXRPC. It is being considered for a future release.

Dima Sennikov wrote:

>Hello, All.
>
>I have a problem. The dynamic client is necessary for me and it is necessary to receive mine Exceptions.
>I write my web-service with one method. He throws MyException.
>
>public interface ITestServer
> extends Remote
>{
> public void getException() throws MyException, RemoteException;
>}
>
>public class TestServer
> implements ITestServer
>{
> public void getException() throws MyException, RemoteException
> {
> throw new MyException();
> }
>}
>
>After deploy server.
>If i use static client all ok. I got MyException.
>public class StaticClient
>{
> public static void main(String[] args)
> {
> ITestServer testServer = null;
> try
> {
> testServer = new TestServer_Impl().getITestServerPort();
> testServer.getException();
>
> }
> catch(MyException e)
> {
>// I got it
> System.out.println("e MyException");
> e.printStackTrace();
> }
> catch(RemoteException e)
> {
> System.out.println("e RemoteException");
> e.printStackTrace();
> }
> catch(Exception e)
> {
> System.out.println("e Exception");
> e.printStackTrace();
> }
> }
>}
>
>But if write dynamic client. I didn`t get MyException
>
>public class DynamicClient
>{
> public static void main(String[] args)
> {
> String serviceName = "TestServer";
> String wsdlLocation = "http://localhost:8080/TestServer.wsdl";
> String nameSpaceURI = "http://test.org/wsdl";
> String portName = "ITestServerPort";
>
> ITestServer testServer = null;
> try
> {
> URL testServerWsdlUrl = new URL(wsdlLocation);
>
> Service service = ServiceFactory.newInstance().createService(
> testServerWsdlUrl,
> new QName(nameSpaceURI, serviceName));
> testServer = (ITestServer) service.getPort(
> new QName(nameSpaceURI, portName),
> ITestServer.class);
> System.out.println("1");
>
> testServer.getException();
> System.out.println("2");
>
> System.out.println("SUCCESS!!!!");
>
> }
> catch(MyException e)
> {
> System.out.println("e MyException");
> e.printStackTrace();
> }
> catch(MalformedURLException e)
> {
> System.out.println("e MalformedURLException");
> e.printStackTrace();
> }
> catch(RemoteException e)
> {
> System.out.println("e RemoteException");
> e.printStackTrace();
> }
> catch(Exception e)
> {
> System.out.println("e Exception");
> e.printStackTrace();
> }
> }
>}
>
>I hope to receive MyException, but I receive RemoteException.
>Out:
>1
>e RemoteException
>java.rmi.ServerException: test.server.MyException
> at com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.java:346)
> at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:221)
> at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:54)
> at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:259)
> at com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.java:96)
> at com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.java:68)
> at $Proxy0.getException(Unknown Source)
> at test.client.Client.main(Client.java:41)
>
>How get MyException, or what i do wrong?
>
>--
>Best regards,
> Dima
>
>

--
-----------------------------------------------------------------------
Phil Goodwin, Java Software, Sun Microsystems, 408.276.7090, or x17090
For a bowl of water give a goodly meal;
For a kindly greeting bow thou down with zeal;
For a simple penny pay thou back with gold;
If thy life be rescued, life do not withhold.
Thus the words and actions of the wise regard;
Every little service tenfold they reward.
But the truly noble know all men as one,
And return with gladness good for evil done.