访问 Web 服务::架构问题

发布于 2024-10-21 07:39:45 字数 6217 浏览 1 评论 0原文

我有基于教程示例的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

行雁书 2024-10-28 07:39:45

你有 http://localhost:8080/ws/holidayService/ 而不是 /HumanService/

Have you http://localhost:8080/ws/holidayService/ instead of /HumanService/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文