java - ValidationHandler not called in metro -
i have sample project test schema validation in jaxws. use metro 2.3.1 , spring in server side.
import javax.jws.webmethod; import javax.jws.webservice; import com.sun.xml.internal.ws.developer.schemavalidation; @schemavalidation(handler = myerrorhandler.class) @webservice public class testws { @webmethod public string firstmethod() { return "hi"; } } import org.xml.sax.saxparseexception; import org.xml.sax.saxexception; import com.sun.xml.internal.ws.developer.validationerrorhandler; public class myerrorhandler extends validationerrorhandler { public void warning(saxparseexception e) throws saxexception { system.out.println("warning"); } public void error(saxparseexception e) throws saxexception { system.out.println("error"); } public void fatalerror(saxparseexception e) throws saxexception { system.out.println("fatal"); } }
then generate soap message soap ui
following:
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test/"> <soapenv:header/> <soapenv:body> <test:firstmethod/> </soapenv:body> </soapenv:envelope>
and following answer:
<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:body> <ns2:firstmethodresponse xmlns:ns2="http://test/"> <return>hi</return> </ns2:firstmethodresponse> </s:body> </s:envelope>
this normal soap message request , response when create incorrect soap message following:
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test/"> <soapenv:header/> <soapenv:body> <test:firstmethod1/> </soapenv:body> </soapenv:envelope>
i append 1 number last of service method : firstmethod create wrong message , after send message server following response :
<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-elt.1: cannot find declaration of element 'test:firstmethod11'.</faultstring> </s:fault> </s:body> </s:envelope>
and in server side following text logged:
error fatal
but when none soap message such empty-test
send server handler class not called , server log messagecreationexception
.
or when create soap incorrect message such following changed test
tessst
, request don't send server handler class not caller.
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test/"> <soapenv:header/> <soapenv:body> <tessst:firstmethod/> </soapenv:body> </soapenv:envelope>
my question : when validationerrorhandler class called? don't understand obvious. not found clear response in internet.
Comments
Post a Comment