|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
Client-side handler problemHello, this problem is also described on my website :
http://bernard.labno.pl/?action=jax_rpcsample I have included there sources of sample application. I have run into a problem concerning jax.xml.rpc.handler.Handler. A third-party Webservice I wanted to interact with did not define business exceptions in their WSDL file, so when they were thrown i got strange exception and could not determine the true reason of exception. class java.rmi.RemoteException Cause:class com.sun.xml.rpc.encoding.DeserializationException java.rmi.RemoteException: Runtime exception; nested exception is: deserialization error: XML reader error: unexpected character content: "doSearch - Wrong session" I decided to use handlers to parse SOAP messages before they get to JAX-RPC. If they would contain undefined business exception, than handler would throw known exception with details from intercepted messsage. Unfortunately I recived strange exceptions when I tried to get HandlerChaing from the service. Sometimes it was java.lang.UnsupportedOperationException and sometimes IllegalAccessException. After building my project with various configurations I found out that the problem disappeares when client does not use JavaEE container generated stub. Below are sources of simple "Hello service" and two client web applications. The only difference between those clients is that one uses ide-generated stub and the other uses container-generated stub. Just to clarify I explain that ide-generated stub is made using "wscompile" with "-gen:client" option. Container-generated stub is made using "wscompile" with "-import" option. Code differences Following code is in Test servlet's processRequest method. From client with container-generated stub : -------------- JAX_RPCSampleService service = getJAX_RPCSampleService(); //this method is of course not in processRequest but next to it private JAX_RPCSampleService getJAX_RPCSampleService() { JAX_RPCSampleService jAX_RPCSampleService = null; try { javax.naming.InitialContext ic = new javax.naming.InitialContext(); jAX_RPCSampleService = (JAX_RPCSampleService) ic.lookup("java:comp/env/service/JAX_RPCSampleService"); } catch(javax.naming.NamingException ex) { // TODO handle JNDI naming exception } return jAX_RPCSampleService; } -------------- From client with ide-generated stub -------------- JAX_RPCSampleService service = new JAX_RPCSampleService_Impl(); -------------- Common code -------------- //here goes code from one of two previous codes final QName serviceName = new QName("urn:JAX_RPCSampleService/wsdl", "JAX_RPCSampleService"); final QName ns1_JAX_RPCSampleServiceSEIPort_QNAME = new QName("urn:JAX_RPCSampleService/wsdl", "JAX_RPCSampleServiceSEIPort"); HandlerInfo hi = new HandlerInfo(); hi.setHandlerClass(MessageHandler.class); service.getHandlerRegistry().getHandlerChain(ns1_JAX_RPCSampleServiceSEIPort_QNAME).add(hi); try { JAX_RPCSampleServiceSEI sei = service.getJAX_RPCSampleServiceSEIPort(); out.println(sei.sayHello(request.getParameter("name"))); } catch (RemoteException ex) { ex.printStackTrace(); throw new ServletException(ex); } catch (WrongArgumentException ex) { out.println("Exception : "+ex.getMessage()); } catch (ServiceException ex) { ex.printStackTrace(); throw new ServletException(ex); } -------------- Questions 1. Is it possible to use container-generated stub and attach a client-side handler to it ? 2. If it is possible than what is wrong with presented client ? -- Bernard Łabno --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |