aspose file tools*
The moose likes Web Services and the fly likes Validation of  incoming SOAP message using JAX-WS in JWSDP 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Validation of  incoming SOAP message using JAX-WS in JWSDP 2.0" Watch "Validation of  incoming SOAP message using JAX-WS in JWSDP 2.0" New topic
Author

Validation of incoming SOAP message using JAX-WS in JWSDP 2.0

Sasanka Reddy Vanga
Greenhorn

Joined: Apr 26, 2007
Posts: 1
Hi,

There is a project requirement of validating the incoming soap message using JAX-WS API in JWSDP 2.0. The application is deployed in Tomcat 5.5.20 server.

As suggested in one of the sites, we created sample application for validating the message using handler class. Pls fid the code snippet below. But when we hit the web service, it throws an error at runtime which is shown below.

Pls suggest me the solution if any.


private boolean processMessage(LogicalMessageContext context) {
boolean processa = true;
Boolean outboundProperty = (Boolean) context
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (!outboundProperty) {
System.out.println("inside if ");
LogicalMessage lm = context.getMessage();
System.out.println("LogicalMessage is "+lm.toString());
Source payload = lm.getPayload();
System.out.println("Source"+payload);
JAXBContext jaxbContext = null;
try {
System.out.println("inside try block");
jaxbContext = JAXBContext
.newInstance("fromwsdlhandler.server");

System.out.println("JAXBContext new instance created...");
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
System.out.println("after creating unmarsheller "+unmarshaller);
SchemaFactory factory = SchemaFactory
.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

System.out.println("after creating SchemaFactory "+factory);
unmarshaller.setSchema(factory.newSchema(new StreamSource(((ServletContext) context
.get(context.SERVLET_CONTEXT))
.getResourceAsStream("/WEB-INF/wsdl/AddNumbers.xsd"))));

System.out.println("after setSchema ");
JAXBElement myJAXB = (JAXBElement) unmarshaller.unmarshal(payload);
System.out.println("after unmarshelling....."+myJAXB);
} catch (Exception ex) {
System.out.println("in catch block....");
String ff = "<Fault xmlns:ns3=\"http://www.w3.org/2003/05/soap-envelope\"><faultcode>S:Server</faultcode><faultstring>Richiesta non corretta</faultstring></Fault>";
lm.setPayload(new SAXSource(new InputSource(
new StringReader(ff))));
processa = false;
}
}
return processa;
}




Error in decoding SOAP Message

at com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.toInternalMessage(SOAPXMLDecoder.java:131)

at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.toMessageInfo(SOAPMessageDispatcher.java:173)

at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher$SoapInvoker.invoke(SOAPMessageDispatcher.java:533)

at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:144)

at com.sun.xml.ws.server.Tie.handle(Tie.java:88)

at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.handle(WSServletDelegate.java:279)

at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:232)

at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:77)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Unknown Source)

Caused by: javax.xml.ws.soap.SOAPFaultException: Cannot find the dispatch method

at com.sun.xml.ws.encoding.soap.SOAPDecoder.raiseFault(SOAPDecoder.java:662)

at com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.decodeDispatchMethod(SOAPXMLDecoder.java:151)

at com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBodyContent(SOAPDecoder.java:335)

at com.sun.xml.ws.encoding.soap.SOAPDecoder.convertBodyBlock(SOAPDecoder.java:386)

at com.sun.xml.ws.encoding.soap.server.SOAPXMLDecoder.toInternalMessage(SOAPXMLDecoder.java:124)


Regards,
Sasanka


regards,<br />Sasanka
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
Welcome to JavaRanch.

In which line is the exception thrown?


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation of incoming SOAP message using JAX-WS in JWSDP 2.0