aspose file tools*
The moose likes Web Services and the fly likes Web Service Request Validation against WSDL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web Service Request Validation against WSDL" Watch "Web Service Request Validation against WSDL" New topic
Author

Web Service Request Validation against WSDL

Sudhakar Jampa
Greenhorn

Joined: Jan 29, 2005
Posts: 7
Any idea how to do Web Service Request Validation against Schema (WSDL file)in case of a Doc/Wrapped Service.

My idea is to create the XML out of request and validate it with WSDL file I have. But I'm not able to generate XML from my Request Object.



SCJP 1.5, PMP
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
In both JAX-RPC and JAX-WS message header and payload validation would typically happen in a MessageHandler. If validation fails the handler would initiate the SOAPFault and the service application will never see the request.

Writing a Handler in JAX-WS

The SOAPHandler receives a SOAPMessageContext. With SOAPMessageContext.getMessage().getSOAPBody() you can get the javax.xml.soap.SOAPBody which implements org.w3c.dom.Element which ultimately gives you access to the SOAP payload (XML document) which you should be able to validate. Raise a javax.xml.ws.ProtocolException if the validation fails. At this point fault processing begins and the handleFault method is called on the handlers that have already processed the in-bound request in reverse order. That means that your validation handler is the first handler called - so you assemble the fault response in its handleFault method (if it was the one that threw the ProtocolException in the first place). Alternately you could just simply build the fault in handleMessage and give it to the SOAPFaultException that you throw (example).

See JSR-000224 JavaTM API for XML-Based Web Services 2.0 (Final Release) for details.


In JAX-RPC you would use javax.xml.rpc.handler.Handler. You would perform the validation on the handleRequest method. javax.xml.rpc.handler.MessageContext is in fact a javax.xml.rpc.handler.soap.SOAPMessageContext which also has a getMessage() method ultimately giving you access to the SOAP payload. If validation fails you throw a javax.xml.rpc.soap.SOAPFaultException. The handlers handleFault method is immediately invoked by the container where you can assemble the fault response.
[ March 04, 2008: Message edited by: Peer Reynders ]

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Service Request Validation against WSDL
 
Similar Threads
wsdl and xsd.
Basic SOAP fault question
WebSphere webservice
WSDL importing xsd containg DTD, prohibited?
web service questions to ask based on the client wsdl file and XML sample files