访问 Web 服务::架构问题
我有基于教程示例的Spring Web服务。以这种方式配置的
@Endpoint
public class HolidayEndpoint {
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest")
public void handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception {...}
web.xml
<servlet>
<servlet-name>spring-ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
spring config
<sws:annotation-driven/>
<sws:dynamic-wsdl id="holiday" portTypeName="HumanResource" locationUri="/holidayService/"
targetNamespace="http://mycompany.com/hr/definitions">
<sws:xsd location="/WEB-INF/somexsd.xsd"/>
</sws:dynamic-wsdl>
我应该如何访问它?
我尝试在 http://localhost:8080/ws/holidayService/holiday
发帖,但服务器返回 404
并
开始时
DEBUG [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping] - Looking for endpoints in application context: WebApplicationContext for namespace 'spring-ws-servlet': startup date [Fri Mar 11 18:41:42 EET 2011]; root of context hierarchy
DEBUG [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping] - Mapped [{http://mycompany.com/hr/schemas}HolidayRequest] onto endpoint [public void com.mycompany.hr.ws.HolidayEndpoint.handleHolidayRequest(org.jdom.Element) throws java.lang.Exception]
DEBUG [org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping] - Looking for endpoints in application context: WebApplicationContext for namespace 'spring-ws-servlet': startup date [Fri Mar 11 18:41:42 EET 2011]; root of context hierarchy
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.InliningXsdSchemaTypesProvider] - Inlining SimpleXsdSchema{http://mycompany.com/hr/schemas}
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.DefaultMessagesProvider] - Looking for elements in schema with target namespace [http://mycompany.com/hr/schemas]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.DefaultMessagesProvider] - Creating message [{http://mycompany.com/hr/definitions}HolidayRequest]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.SuffixBasedPortTypesProvider] - Creating port type [{http://mycompany.com/hr/definitions}HumanResource]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.SuffixBasedPortTypesProvider] - Adding operation [Holiday] to port type [{http://mycompany.com/hr/definitions}HumanResource]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.Soap11Provider] - Creating binding [{http://mycompany.com/hr/definitions}HumanResourceSoap11]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.Soap11Provider] - Creating service [{http://mycompany.com/hr/definitions}HumanResourceService]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.Soap11Provider] - Adding port [HumanResourceSoap11] to service [{http://mycompany.com/hr/definitions}HumanResourceService]
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - Published WebApplicationContext of servlet 'spring-ws' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring-ws]
INFO [org.springframework.ws.soap.saaj.SaajSoapMessageFactory] - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
DEBUG [org.springframework.ws.soap.saaj.SaajSoapMessageFactory] - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - No WebServiceMessageFactory found in servlet 'spring-ws': using default
DEBUG [org.springframework.ws.soap.server.SoapMessageDispatcher] - No EndpointExceptionResolvers found, using defaults
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - No MessageDispatcher found in servlet 'spring-ws': using default
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - Published [org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition@6fc41e49] as holiday.wsdl
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - Published [SimpleXsdSchema{http://mycompany.com/hr/schemas}] as org.springframework.xml.xsd.SimpleXsdSchema#0.xsd
在每个请求
DEBUG [org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter] - Accepting incoming [org.springframework.ws.transport.http.HttpServletConnection@3bd85e85] at [http://localhost:8080/ws/holidayService/holiday]
DEBUG [org.springframework.ws.server.MessageTracing.received] - Received request [SaajSoapMessage HolidayRequest]
DEBUG [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping] - Looking up endpoint for [HolidayRequest]
DEBUG [org.springframework.ws.soap.server.SoapMessageDispatcher] - Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping@2081ca25] has no mapping for request
DEBUG [org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping] - Looking up endpoint for []
DEBUG [org.springframework.ws.soap.server.SoapMessageDispatcher] - Endpoint mapping [org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping@3ad8326d] has no mapping for request
WARN [org.springframework.ws.server.EndpointNotFound] - No endpoint mapping found for [SaajSoapMessage HolidayRequest]
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - Successfully completed request
写入日志如果您需要一些其他信息请告诉我。
UPD 它可以在没有方案/命名空间的情况下工作。
I have Spring Web Service based on tutorial example. That configured in this way
@Endpoint
public class HolidayEndpoint {
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest")
public void handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception {...}
web.xml
<servlet>
<servlet-name>spring-ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
spring config
<sws:annotation-driven/>
<sws:dynamic-wsdl id="holiday" portTypeName="HumanResource" locationUri="/holidayService/"
targetNamespace="http://mycompany.com/hr/definitions">
<sws:xsd location="/WEB-INF/somexsd.xsd"/>
</sws:dynamic-wsdl>
How I should access it?
I've tried to post at http://localhost:8080/ws/holidayService/holiday
but server returned 404
and wrote in log
at starting
DEBUG [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping] - Looking for endpoints in application context: WebApplicationContext for namespace 'spring-ws-servlet': startup date [Fri Mar 11 18:41:42 EET 2011]; root of context hierarchy
DEBUG [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping] - Mapped [{http://mycompany.com/hr/schemas}HolidayRequest] onto endpoint [public void com.mycompany.hr.ws.HolidayEndpoint.handleHolidayRequest(org.jdom.Element) throws java.lang.Exception]
DEBUG [org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping] - Looking for endpoints in application context: WebApplicationContext for namespace 'spring-ws-servlet': startup date [Fri Mar 11 18:41:42 EET 2011]; root of context hierarchy
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.InliningXsdSchemaTypesProvider] - Inlining SimpleXsdSchema{http://mycompany.com/hr/schemas}
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.DefaultMessagesProvider] - Looking for elements in schema with target namespace [http://mycompany.com/hr/schemas]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.DefaultMessagesProvider] - Creating message [{http://mycompany.com/hr/definitions}HolidayRequest]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.SuffixBasedPortTypesProvider] - Creating port type [{http://mycompany.com/hr/definitions}HumanResource]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.SuffixBasedPortTypesProvider] - Adding operation [Holiday] to port type [{http://mycompany.com/hr/definitions}HumanResource]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.Soap11Provider] - Creating binding [{http://mycompany.com/hr/definitions}HumanResourceSoap11]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.Soap11Provider] - Creating service [{http://mycompany.com/hr/definitions}HumanResourceService]
DEBUG [org.springframework.ws.wsdl.wsdl11.provider.Soap11Provider] - Adding port [HumanResourceSoap11] to service [{http://mycompany.com/hr/definitions}HumanResourceService]
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - Published WebApplicationContext of servlet 'spring-ws' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring-ws]
INFO [org.springframework.ws.soap.saaj.SaajSoapMessageFactory] - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
DEBUG [org.springframework.ws.soap.saaj.SaajSoapMessageFactory] - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - No WebServiceMessageFactory found in servlet 'spring-ws': using default
DEBUG [org.springframework.ws.soap.server.SoapMessageDispatcher] - No EndpointExceptionResolvers found, using defaults
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - No MessageDispatcher found in servlet 'spring-ws': using default
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - Published [org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition@6fc41e49] as holiday.wsdl
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - Published [SimpleXsdSchema{http://mycompany.com/hr/schemas}] as org.springframework.xml.xsd.SimpleXsdSchema#0.xsd
per request
DEBUG [org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter] - Accepting incoming [org.springframework.ws.transport.http.HttpServletConnection@3bd85e85] at [http://localhost:8080/ws/holidayService/holiday]
DEBUG [org.springframework.ws.server.MessageTracing.received] - Received request [SaajSoapMessage HolidayRequest]
DEBUG [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping] - Looking up endpoint for [HolidayRequest]
DEBUG [org.springframework.ws.soap.server.SoapMessageDispatcher] - Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping@2081ca25] has no mapping for request
DEBUG [org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping] - Looking up endpoint for []
DEBUG [org.springframework.ws.soap.server.SoapMessageDispatcher] - Endpoint mapping [org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping@3ad8326d] has no mapping for request
WARN [org.springframework.ws.server.EndpointNotFound] - No endpoint mapping found for [SaajSoapMessage HolidayRequest]
DEBUG [org.springframework.ws.transport.http.MessageDispatcherServlet] - Successfully completed request
If you need some additional info let me know, please.
UPD It worked without scheme/namespace stuff.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你有 http://localhost:8080/ws/holidayService/ 而不是 /HumanService/
Have you http://localhost:8080/ws/holidayService/ instead of /HumanService/