Hi there,
I am a newbie of CXF, and I just created a client using wsdl2java. It works
fine until I started to test its exception feature. I shortened the timeout
properties to extremely low (1 ms) to simulate the server time out scene. I did
succeed in getting the timeout exception, but I couldn't catch the exception as
exemplified in the code below
// start of code
try {
myClient.queryServer(); // query web service
} catch (Exception e) {
System.out.println("Caught exception"); // this has never been run so far for
some reason
}
// end of code
In real life runs, my application always skips the catch section code
completely. It did print out exception message to the standard output,
something like:
WARNING: Interceptor for
{http://mytestcom.com/}MyService#{http://mytesturl.com/}MyMethod has thrown
exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:533)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
at $Proxy25.MyMethod(Unknown Source)
at com.mytestcom.service....myMethod(MyClient.java:69)
at MyTest.main(MyTest.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
It seems that the CXF library stores exception in a variable and didn't
interrupt my code, and there was no exception to be caught by my own code.
My question is whether I can change this behavior to activate a real exception
so my client code can handle it at my own will, e.g., displaying an elegant
message to my user saying that the web server is too slow to respond.
Thanks!
Hongyu