无法访问Web服务端点:Spring-WS 2

问题描述:

我是Spring-WS的新手,我根据从JAXB注释类生成的模式定义了一个端点。但是,当我尝试通过soapUI访问端点时,我收到以下错误以及404响应代码:

I'm new to Spring-WS and I have defined an endpoint based off a schema generated from JAXB annotated classes. However, when I try to access the endpoint via soapUI, I get the following error along with a 404 response code:

找不到端点映射[SaajSoapMessage {clip} clipClaimRequest]

关于我做错了什么的任何想法?感谢您提供的任何帮助。

Any ideas as to what I'm doing wrong? Thanks for any help given.

端点类:

@Endpoint
public class TestEndpoint {

    @PayloadRoot(localPart = "clipClaimRequest", namespace = "clip")
    @ResponsePayload
    public CLIPClaimResponse registerClaim(@RequestPayload CLIPClaimRequest request) {
        return new CLIPClaimResponse("Success", "test success");
    }
}

请求/响应类(通过JAXB编组/解组) ):

The request/response classes (marshalled/unmarshalled via JAXB):

@XmlRootElement(name = "clipClaimRequest")
@XmlType(name = "CLIPClaimRequest")
public class CLIPClaimRequest {
    private Claim claim;

    @XmlElement(required = true)
    public Claim getClaim() {
        return claim;
    }

    public void setClaim(Claim claim) {
        this.claim = claim;
    }

}

并且:

@XmlRootElement(name = "clipClaimResponse")
@XmlType(name = "CLIPClaimResponse")
public class CLIPClaimResponse {
    private String code;
    private String description;

    public CLIPClaimResponse() {
    }

    public CLIPClaimResponse(String code, String desc) {
        setCode(code);
        setDescription(desc);
    }

    @XmlElement(required = true)
    public String getCode() {
        return code;
    }

    @XmlElement(required = true)
    public String getDescription() {
        return description;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}

web.xml servlet配置:

web.xml servlet configuration:

<servlet>
    <servlet-name>spring-ws</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    <init-param>
        <description>This is used by SpringWS to dynamically convert WSDL urls</description>
        <param-name>transformWsdlLocations</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring-ws</servlet-name>
    <url-pattern>/clipClaimService/*</url-pattern>
</servlet-mapping>

spring-ws-servlet.xml 配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans>
    <context:annotation-config />
    <sws:annotation-driven />
    <sws:dynamic-wsdl id="claimRegistration" portTypeName="CLIPClaimPort"
        locationUri="/clipClaimService/" targetNamespace="clip">
        <sws:xsd location="/WEB-INF/CLIP_Poc.xsd" />
    </sws:dynamic-wsdl>
    <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="classesToBeBound">
            <list>
                <!-- list of classes... -->
            </list>
        </property>
        <property name="schema" value="/WEB-INF/CLIP_PoC.xsd" />
    </bean>

    <bean id="marshallingPayloadMethodProcessor"
        class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
        <constructor-arg ref="jaxb2Marshaller" />
        <constructor-arg ref="jaxb2Marshaller" />
    </bean>

    <bean id="defaultMethodEndpointAdapter"
        class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
        <property name="methodArgumentResolvers">
            <list>
                <ref bean="marshallingPayloadMethodProcessor" />
            </list>
        </property>
        <property name="methodReturnValueHandlers">
            <list>
                <ref bean="marshallingPayloadMethodProcessor" />
            </list>
        </property>
    </bean>
</beans>

最后, CLIP_PoC.xsd ,生成WSDL的模式:

And finally, CLIP_PoC.xsd, the schema from which the WSDL was generated:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="clip" targetNamespace="clip" version="1.0">
    <xs:element name="clipClaimRequest" type="CLIPClaimRequest"/>
    <xs:element name="clipClaimResponse" type="CLIPClaimResponse"/>
    <!-- type definitions for all the complex elements used... -->
</xs:schema>


我弄清楚了。我忘了在我的弹簧中放置:< context:component-scan base-package =my.base.package/> ws-servlet.xml 文件。这以某种方式修复了它。

I figured it out. I had forgotten to put: <context:component-scan base-package="my.base.package"/> in my spring-ws-servlet.xml file. This fixed it somehow.