简体   繁体   English

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

[英]Unable to access web service endpoint: Spring-WS 2

I'm new to Spring-WS and I have defined an endpoint based off a schema generated from JAXB annotated classes. 我是Spring-WS的新手,我根据从JAXB注释类生成的模式定义了一个端点。 However, when I try to access the endpoint via soapUI, I get the following error along with a 404 response code: 但是,当我尝试通过soapUI访问端点时,我得到以下错误以及404响应代码:

No endpoint mapping found for [SaajSoapMessage {clip}clipClaimRequest]

Any ideas as to what I'm doing wrong? 关于我做错了什么的任何想法? Thanks for any help given. 谢谢你给予的任何帮助。

The endpoint class: 端点类:

@Endpoint
public class TestEndpoint {

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

The request/response classes (marshalled/unmarshalled via JAXB): 请求/响应类(通过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;
    }

}

And: 和:

@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 configuration: web.xml servlet配置:

<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 configuration: 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>

And finally, CLIP_PoC.xsd , the schema from which the WSDL was generated: 最后, CLIP_PoC.xsd ,生成WSDL的模式:

<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>

I figured it out. 我想到了。 I had forgotten to put: <context:component-scan base-package="my.base.package"/> in my spring-ws-servlet.xml file. 我忘记在我的spring-ws-servlet.xml文件中输入: <context:component-scan base-package="my.base.package"/> This fixed it somehow. 这以某种方式修复了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM