2013-09-26 18 views
0

我使用JIBX從XSD文件創建我的實體類。它在pom.xml中配置,並在我做「maven:compile」時創建類。Spring WS + JIBX「沒有端點適配器」錯誤

我也使用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 /請求類。

我的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 file is;

<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,它的工作!

+0

您是否嘗試使用soapAction代替PayloadRoot(對於ex SoapAction(「nmapespace/getTransactionsRequest」)? – VirtualTroll

回答

0

端點映射使用基於名稱空間和@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)。

+0

我已經添加了wsdl – Spring

+0

@Spring的一部分,但問題可能在於您未顯示的部分。其中一個。你能夠從服務器訪問wsdl嗎? – Erich

+0

是的,我可以達到 – Spring

0

我也有類似的問題(花了好幾天),但是在我的情況下,問題是Spring WS和Spring版本不兼容,請檢查您的Spring WS和Spring版本是否匹配。