I have a WCF web service which is working seamlessly. Now the aim is to generate a Java proxy to access this web service. I have installed the newest Eclipse with the WTP extension and generated the WebClient (proxy, stub, etc.). I made a web service call which succeeded. On the other side, when I shut down the web service, the call succeeded as well. What am I doing wrong, does the proxy not throw an EndpointNotFoundException or RemoteException when the service is not available?
Here is my sample code:
try
{
IRemoteControlProxy rc = new IRemoteControlProxy("http://localhost:666/MyService");
rc.InsertOrUpdate(0, new DtoObj());
}
catch (RemoteException e)
{
System.out.println(e);
}
catch (ServiceException e)
{
System.out.println(e);
}
System.out.println("No exception");
I get only the "No Exception" even though the call must have failed. I checked the default URL in the proxy and there is no web service running at this URL, I double checked the URL with the Internet Explorer. I still don't get any EndpointNotFoundException, why? Do I even instantiate the right object (the one ending with "proxy")?
Notice that if the service is running properly, the communication works seamlessly.
Well, the problem here was that I added the "IsOneWay" attribute to the service method definition. In this case, the generated proxy calls invokeOneWay(), which is basically fire&forget. This method does not throw any exception when the target is not available.
If I remove the "IsOneWay" attribute from the service method definition, the proxy calls invoke() which throw a proper exception when the target is not available.