【问题标题】:Spring WS + JIBX "No adapter for endpoint" ErrorSpring WS + JIBX“端点没有适配器”错误
【发布时间】:2013-09-26 15:45:38
【问题描述】:

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

我也使用 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 时,它起作用了!

【问题讨论】:

  • 您是否尝试过使用soapAction 而不是PayloadRoot(例如SoapAction("nmapespace/getTransactionsRequest")?

标签: java web-services soap spring-ws jibx


【解决方案1】:

端点映射存储在哈希映射中,其键基于命名空间和@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;
    }
}

如果这不是问题,您可能需要在问题中添加更多信息(soap 请求、xsds、wsdl)。

【讨论】:

  • @Spring 但问题可能出在您未显示的部分。命名空间就是其中之一。您可以从服务器访问 wsdl 吗?
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多