@SchemaValidation does the trick checkout the sample code below
package com.palm.appstore.wsc;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import com.sun.xml.ws.developer.SchemaValidation;
/**
*
* @author Intesar Mohammed
*/
@WebService(serviceName = "Echo")
@SchemaValidation
public class Echo {
/** This is a sample web service operation */
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "no") int txt) {
return "Hello " + txt + " !";
}
}
Valid Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsc="http://wsc.appstore.palm.com/">
<soapenv:Header/>
<soapenv:Body>
<wsc:hello>
<no>33</no>
</wsc:hello>
</soapenv:Body>
</soapenv:Envelope>
Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:helloResponse xmlns:ns2="http://wsc.appstore.palm.com/">
<return>Hello 33 !</return>
</ns2:helloResponse>
</S:Body>
</S:Envelope>
InValid Request without @SchemaValidation
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:helloResponse xmlns:ns2="http://wsc.appstore.palm.com/">
<!�missing no element -- >
</ns2:helloResponse>
</S:Body>
</S:Envelope>
Response
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:helloResponse xmlns:ns2="http://wsc.appstore.palm.com/">
<return>Hello 0 !</return>
</ns2:helloResponse>
</S:Body>
</S:Envelope>
InValid Request with @SchemaValidation
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:helloResponse xmlns:ns2="http://wsc.appstore.palm.com/">
<!�missing no element -- >
</ns2:helloResponse>
</S:Body>
</S:Envelope>
Response (Auto Validated)
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Client</faultcode>
<faultstring>org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of element 'wsc:hello' is not complete. One of '{no}' is expected.</faultstring>
---
</s:Envelope>
Comments