1

嗨,我创建了我的第一个 Web 服务。它工作正常,但现在我需要解决一些特殊情况。第一种情况是这里提到的Spring Web Services - Exception Skipping ExceptionResolver但是没有可以帮助我的解决方案。

第二种情况是客户端向我发送正确的 SOAP 消息但在命名空间中出错,例如发送给我: xmlns:urn="urn:org:samples:spring:ws:schemas:calculatorblabla" 但正确的命名空间是 xmlns:urn="urn1:org:samples:spring:ws:schemas:calculator"。因此,当客户向我发送带有错误名称空间的消息时,他不会收到他犯错误的消息:

<html><head><title>SpringSource tc Server/6.0.20.C - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The requested resource () is not available.</u></p><HR size="1" noshade="noshade"><h3>SpringSource tc Server/6.0.20.C</h3></body></html>

我用 SoapUI 测试了这些情况

服务器收到消息但没有发送任何响应,因为他没有找到正确的端点[2010-08-26 14:38:19] Accepting incoming [org.springframework.ws.transport.http.HttpServletConnection@1700f3d] at [http://localhost:8080/calculator] [2010-08-26 14:38:19] Received request [SaajSoapMessage {urn:org:samples:spring:ws:schemas:calculatorblabla}calculatorRequest] [2010-08-26 14:38:19] Looking up endpoint for [{urn:org:samples:spring:ws:schemas:calculatorblabla}calculatorRequest] [2010-08-26 14:38:19] Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping@ae2481] has no mapping for request [2010-08-26 14:38:19] No endpoint mapping found for [SaajSoapMessage {urn:org:samples:spring:ws:schemas:calculatorblabla}calculatorRequest] [2010-08-26 14:38:19] Successfully completed request

所以我需要当客户端向我发送带有错误名称空间的消息时,它会在他发送未使用 xsd 验证的 xml 时写入一些类似的错误消息。感谢您的帮助,对不起,我的英语很糟糕

4

1 回答 1

0

默认情况下 Spring-WS 1.5.x 使用org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapterwhich used org.springframework.ws.transport.http.HttpServletConnectionto send WebServiceMessages. HttpServletConnection定义EndpointAwareWebServiceConnection了一种在找不到端点时处理情况的方法。默认实现将 servlet 响应代码设置为 404。

如果您需要做其他事情,则需要亲身体验 Spring-WS,因为WebServiceConnectionWebServiceMessageReceiverHandlerAdapter. 我不知道另一个HandlerAdapter允许您配置的,WebServiceConnection因此您可能必须编写一个。

于 2010-08-31T18:59:23.057 回答