|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Is it possible to return a customized fault, when receiving malformed xml?Hello,
assuming the client sends following malformed xml: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://acme.com"> <soapenv:Header/> <soapenv:Body> <foo>?</fo> </soapenv:Body> </soapenv:Envelope> This results in following WebServiceException on the server side javax.xml.ws.WebServiceException: Failed to copy a message at com.sun.xml.ws.message.stream.StreamMessage.copy(StreamMessage.java:432) at com.sun.xml.ws.util.pipe.AbstractSchemaValidationTube.doProcess(AbstractSchemaValidationTube.java:199) at com.sun.xml.ws.util.pipe.AbstractSchemaValidationTube.processRequest(AbstractSchemaValidationTube.java:175) at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598) at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557) at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542) at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439) at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243) at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444) at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244) at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135) at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129) at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160) at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:229) at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 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:175) 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:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[7,21] Message: The element type "foo" must be terminated by the matching end-tag "</foo>". at com.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:563) at com.sun.xml.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:92) at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.storeElementAndChildrenNoEx(StreamReaderBufferCreator.java:245) at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.storeElementAndChildren(StreamReaderBufferCreator.java:177) at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.store(StreamReaderBufferCreator.java:142) at com.sun.xml.stream.buffer.stax.StreamReaderBufferCreator.create(StreamReaderBufferCreator.java:82) at com.sun.xml.ws.message.stream.StreamMessage.copy(StreamMessage.java:408) ... 31 more and following soap fault (returning of stack traces turned off) is returned: <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope"> <faultcode>S:Server</faultcode> <faultstring>Failed to copy a message</faultstring> </S:Fault> </S:Body> </S:Envelope> Because this fault isn't really meaningful I want to provide a customized fault, which at least contains the message of the underlying XMLStreamException and a self defined error code. For this I have already a checked exception with a @WebFault annotation. The question is now how can I throw my checked exception instead? I tried using a logical handler to previously parse inbound messages. However this won't work as you can't throw checked exceptions within a handler. Thanks for any ideas and hints. Best regards, Patrick Schmidt [Message sent by forum member 'paschme' (paschme)] http://forums.java.net/jive/thread.jspa?messageID=345887 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Is it possible to return a customized fault, when receiving malformed xml?Hi Patrick
Hopefully the following blog posts are useful in solving your issue: http://one-size-doesnt-fit-all.blogspot.com/2009/04/jax-ws-schemavalidation-custom-handler.html http://one-size-doesnt-fit-all.blogspot.com/2009/05/jax-ws-throwing-generic-soapfaults.html The second post is tailor fitted to WLS but you should be able to get away with the more generic code for throwing a generic fault. Let me know if this is useful. Regards, CM. [Message sent by forum member 'chriscmuir' (chriscmuir)] http://forums.java.net/jive/thread.jspa?messageID=346063 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Is it possible to return a customized fault, when receiving malformed xml?Hi,
thanks for your answer. The first post describes how to throw a checked exception on a schema validation error. However the exception occurs before it comes to the schema validation and therefore this won't work. I also tried to do something similiar in a logical message handler. Accordingly to parse the message previously and set a variable in the LogicalMessageContext on failure. However it seems that these variables aren't available later in the WebServiceContext. The second post describes how to build a SOAPFaultException. However this way you can't customize the SOAPFault-Details in such a convenient way as throwing a checked exception which is automatically converted in the respective details. [Message sent by forum member 'paschme' (paschme)] http://forums.java.net/jive/thread.jspa?messageID=346075 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Is it possible to return a customized fault, when receiving malformed xml?Ah, I see your point and sorry the posts weren't useful.
Question for you, I thought if you removed the @SchemaValidation annotation on your endpoint, a malformed XML payload will be accepted regardless, true? This would suggest using the Provider API, and programatically validating the XML structure may work for you. Sorry I couldn't be more helpful. Regards, CM. [Message sent by forum member 'chriscmuir' (chriscmuir)] http://forums.java.net/jive/thread.jspa?messageID=346249 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Is it possible to return a customized fault, when receiving malformed xml?If I remove the @SchemaValidation annotation the payload still won't be accepted. However I get another exception:
com.sun.xml.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException - with linked exception: [javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,8] Message: The element type "foo" must be terminated by the matching end-tag "</foo>".] at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:245) at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:93) at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598) at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557) at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542) at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439) at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:243) at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:444) at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244) at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135) at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129) at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160) at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:75) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:229) at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 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:175) 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:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:619) Caused by: javax.xml.bind.UnmarshalException - with linked exception: [javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,8] Message: The element type "foo" must be terminated by the matching end-tag "</foo>".] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:422) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360) at com.sun.xml.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:120) at com.sun.xml.bind.api.Bridge.unmarshal(Bridge.java:233) at com.sun.xml.ws.message.stream.StreamMessage.readPayloadAsJAXB(StreamMessage.java:260) at com.sun.xml.ws.server.sei.EndpointArgumentsBuilder$Body.readRequest(EndpointArgumentsBuilder.java:461) at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:243) ... 30 more Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,8] Message: The element type "foo" must be terminated by the matching end-tag "</foo>". at com.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:563) at com.sun.xml.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:92) at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:225) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:358) ... 35 more The resulting response is <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:Server</faultcode> <faultstring>Failed to read a response: javax.xml.bind.UnmarshalException - with linked exception: [javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,8] Message: The element type "foo" must be terminated by the matching end-tag "</foo>".]</faultstring> </S:Fault> </S:Body> </S:Envelope> This is more meaningful, however for this you have to turn off the schema validation and still you can't alter the details.... Thanks a lot for your answers anyway. [Message sent by forum member 'paschme' (paschme)] http://forums.java.net/jive/thread.jspa?messageID=346409 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Is it possible to return a customized fault, when receiving malformed xml?Did you ever find a resolution for this? I'm interested in being able to do a similar thing and raise a generic SOAP Fault for unexpected errors, rather than exposing JAX-B errors.
[Message sent by forum member 'brettbeaumont' (brett.beaumont@...)] http://forums.java.net/jive/thread.jspa?messageID=370413 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |