繁体   English   中英

Spring WS + JIBX“端点无适配器”错误

[英]Spring WS + JIBX “No adapter for endpoint” Error

我使用JIBX从XSD文件创建我的实体类。 它在pom.xml中配置,并在我执行“ maven:编译”时创建类

我也使用spring-ws。 当我用SOAPUI测试我的Web服务时,我得到了臭名昭著的错误。

"No adapter for endpoint GetTransactionsResponse getTransactions(GetTransactionsRequest),  Is your endpoint annotated with @Endpoint, or does.." 

我检查了所有关于该错误的线程,但没有帮助。

我有一个Parent.xsd,它导入了2个子xsd。 它们都在同一个文件夹中。 这就是我的spring-ws-servlet的样子;

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:sws="http://www.springframework.org/schema/web-services"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

<bean name="xsdCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
    <property name="xsds">
        <list>
            <value>/WEB-INF/Parent.xsd</value>
        </list>
    </property>
</bean>


<context:component-scan base-package="mypackage"/>

<sws:annotation-driven/>

<sws:dynamic-wsdl id="my" portTypeName="myResource" locationUri="/ws/my"
                  targetNamespace="myschame">
    <sws:xsd location="/WEB-INF/Parent.xsd"/>
</sws:dynamic-wsdl>

<sws:interceptors>
    <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor">
        <property name="logRequest" value="true"/>
        <property name="logResponse" value="true"/>
    </bean>

    <bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
        <property name="xsdSchemaCollection" ref="xsdCollection"/>
        <property name="validateRequest" value="true"/>
        <property name="validateResponse" value="true"/>
    </bean>
</sws:interceptors>

这是我的终结点课程;

@Endpoint
public class TransactionsEndpoint {

public static final String NAMESPACE = "nmapespace";


@PayloadRoot(namespace = NAMESPACE, localPart = "getTransactionsRequest")
@ResponsePayload
public GetTransactionsResponse getTransactions(@RequestPayload  GetTransactionsRequest request) {
     GetTransactionsResponse transactionsResponse = new GetTransactionsResponse();
     return transactionsResponse;
}


}

JIBX创建的GetTransactionsResponse / Request类。

我的wsdl看起来像这样;

 <wsdl:operation name="getTransactions"><wsdl:input message="tns:getTransactionsRequest" name="getTransactionsRequest">
</wsdl:input><wsdl:output message="tns:getTransactionsResponse" name="getTransactionsResponse">
</wsdl:output></wsdl:operation>

pom文件是;

   <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.ws.xmlschema</groupId>
        <artifactId>xmlschema-core</artifactId>
        <version>2.0.2</version>
    </dependency>

我不确定问题是否是因为存在3个xsd文件,而这些文件之间出了问题,或者是JIBX的配置问题,因为当我尝试使用JAXB而不是JIBX时,它起作用了!

端点映射存储在具有基于名称空间和@PayloadRoot批注的本地部分的键的哈希图中(请参见下面的代码)。 您当前在Java类的命名空间中(我假设是)错别字了……nmapespace而不是命名空间。

如果这与xsd和随后发布的wsdl(未显示)中的内容不匹配,则将找不到映射。 这是您将收到该错误的(众多)可能原因之一。

public class PayloadRootAnnotationMethodEndpointMapping extends 
    AbstractAnnotationMethodEndpointMapping<QName> {

...

@Override
protected QName getLookupKeyForMethod(Method method) {
    PayloadRoot annotation = AnnotationUtils.findAnnotation(method, PayloadRoot.class);
    if (annotation != null) {
        QName qname;
        if (StringUtils.hasLength(annotation.localPart()) && StringUtils.hasLength(annotation.namespace())) {
            qname = new QName(annotation.namespace(), annotation.localPart());
        }
        else {
            qname = new QName(annotation.localPart());
        }
        return qname;
    }
    else {
        return null;
    }
}

如果这不是问题,则可能需要向该问题添加更多信息(肥皂请求,xsds,wsdl)。

我也遇到过类似的问题(花了几天),但是在我的情况下,由于Spring WS和Spring版本不兼容,请检查您的Spring WS和Spring版本是否匹配。

暂无
暂无

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

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