Announcement Announcement Module
Collapse
No announcement yet.
handling parse exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • handling parse exception

    Hi,

    I have a problem with handling org.xml.sax.SAXParseException.
    When client sends me wrong formatted xml message, server throws exception instead of SoapFault custom message.

    Here is fragment of web service :

    SoapFault annotation exception defined in app context :
    Code:
    <bean class="org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver" />
    @SoapFault annotated classes :

    Code:
    @SoapFault(faultCode = FaultCode.CLIENT)
    public class Client extends Exception{
    
    	public Client(String error){
    		super("test test");
    	}
    }
    Code:
    @SoapFault(faultCode = FaultCode.SERVER)
    public class Server extends Exception{
    
    	public Server(String error){
    		super("test test");
    	}
    }
    Server exception :

    Code:
    SEVERE: Servlet.service() for servlet spring-ws threw exception
    org.xml.sax.SAXParseException: cvc-pattern-valid: Value 'test' is not facet-valid with respect to pattern '\d{1,3}\/\d{1,3}' for type 'BPType'.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:410)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3165)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3068)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:2978)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2121)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:791)
    	at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.endElement(ValidatorHandlerImpl.java:563)
    	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.endElement(ValidatingUnmarshaller.java:83)
    	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.endElement(InterningXmlVisitor.java:66)
    	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:145)
    	at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:239)
    	at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:265)
    	at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:234)
    	at com.sun.xml.internal.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:111)
    	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:303)
    	at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:286)
    	at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:107)
    	at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:421)
    	at org.springframework.ws.support.MarshallingUtils.unmarshal(MarshallingUtils.java:62)
    	at org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter.unmarshalRequest(MarshallingMethodEndpointAdapter.java:143)
    	at org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter.invokeInternal(MarshallingMethodEndpointAdapter.java:134)
    	at org.springframework.ws.server.endpoint.adapter.AbstractMethodEndpointAdapter.invoke(AbstractMethodEndpointAdapter.java:58)
    	at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:221)
    	at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:168)
    	at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
    	at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
    	at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:230)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:379)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:619)
    Client exception:

    Code:
    Exception in thread "main" org.springframework.ws.client.WebServiceTransportException: Internal Server Error [500]
    	at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:627)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:551)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:502)
    	at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:457)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:403)
    	at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:394)
    	at org.springframework.ws.spring_ws.HypertensionClient.echo(HypertensionClient.java:51)
    	at org.springframework.ws.spring_ws.HypertensionClient.main(HypertensionClient.java:72)

    How can I send my custom message to client when he sends me wrong message ?

    Can anybody write some example annoted class ?

    Last question is - how can I create different SoapFault message for validation exception and wss exception ?

    I couldn't found any examples in internet instead of one small in documentation which is not very helpfull at all.

    Thanks in advance,

    Michal
Working...
X