users@jax-rpc.java.net

How in the client receive the MyException

From: Dima Sennikov <D.Sennikov_at_PROZA.LVIV.UA>
Date: Fri, 11 Oct 2002 04:40:26 -0600

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