2013-03-07 88 views
6

我只是不能使用Spring Web Services找出這個錯誤。我相信我做的一切都正確。在Spring Web服務響應中沒有端點的適配器

皁錯誤響應

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Header/> 
    <SOAP-ENV:Body> 
     <SOAP-ENV:Fault> 
     <faultcode>SOAP-ENV:Server</faultcode> 
     <faultstring xml:lang="en">No adapter for endpoint [public void org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.PersonManagerSyncSoapBindingImpl.readPerson(org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.ReadPersonRequest,org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.Imsx_RequestHeaderInfoType,org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.holders.ReadPersonResponseHolder,org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.holders.Imsx_ResponseHeaderInfoTypeHolder)]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring> 
     </SOAP-ENV:Fault> 

註解

@Endpoint 
public class PersonManagerSyncSoapBindingImpl implements org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.PersonManagerSyncPortType{ 


    @PayloadRoot(localPart = "readPersonRequest", namespace = "http://www.imsglobal.org/services/lis/pms2p0/wsdl11/sync/imspms_v2p0") 
    @ResponsePayload 
    public void readPerson(@RequestPayload org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.ReadPersonRequest parameters, org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.Imsx_RequestHeaderInfoType headerInfoParameters, @RequestPayload org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.holders.ReadPersonResponseHolder response, @RequestPayload org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.holders.Imsx_ResponseHeaderInfoTypeHolder headerInfoResponse) { 
     response.value = new org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.ReadPersonResponse(); 
     headerInfoResponse.value = new org.imsglobal.www.services.lis.pms2p0.wsdl11.sync.imspms_v2p0.Imsx_ResponseHeaderInfoType(); 
    } 

彈簧-WS-servlet.xml中

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:context="http://www.springframework.org/schema/context" 
      xmlns:sws="http://www.springframework.org/schema/web-services" 
      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.0.xsd"> 

    <context:component-scan base-package="*"></context:component-scan> 
    <sws:annotation-driven/> 

    <sws:dynamic-wsdl id="personServiceManagement"               
     portTypeName="PersonManagerSyncPortType"               
     locationUri="/endpoints/"              
     targetNamespace="http://www.imsglobal.org/services/lis/pms2p0/wsdl11/sync/imspms_v2p0">        
     <sws:xsd location="/WEB-INF/wsdl/xsd/PersonManagementService.xsd"/>             
    </sws:dynamic-wsdl> 

</beans> 

回答

3

我認爲你錯過了返回值。 Spring-WS使用方法簽名來映射請求/響應組合。例如,我在我的生成的WSDL以下操作:

<wsdl:operation name="GetHiredCandidates"> 
    <wsdl:input message="tns:GetHiredCandidatesRequest" name="GetHiredCandidatesRequest"></wsdl:input> 
    <wsdl:output message="tns:GetHiredCandidatesResponse" name="GetHiredCandidatesResponse"></wsdl:output> 
</wsdl:operation> 

要提供關於此操作映射方法的ResponsePayloadRequestPayload需要匹配在WSDL中定義的輸入和輸出:

@ResponsePayload 
public GetHiredCandidatesResponse getKandidaat (@RequestPayload GetHiredCandidatesRequest) { 
    .. 

    return getHiredCandidatesResponse; 
} 

希望這可以幫助!

+0

哈沒有注意到那個的幫助下解決了,但是啊這就說得通了。我轉向其他方面,但我認爲這是問題所在。 – 2013-03-12 15:51:52

18

我有一個類似的錯誤信息。我的問題在於我從XSD生成的請求和響應類。它錯過了@XMLRootElement註釋。這導致操作描述(在WSDL中)和實現方法描述(在Endpoint中)不匹配。 將JAXBElement添加到我的端點方法解決了我的問題。

import javax.xml.bind.JAXBElement; 

@PayloadRoot(namespace = "http://foo.bar/books", localPart = "GetBook") 
@ResponsePayload 
public JAXBElement<MyReponse> getBook(@RequestPayload JAXBElement<MyRequest>) { 
    ... 

看到這個博客瞭解更多詳情:spring-ws: No adapter for endpoint

+0

謝謝!這爲我解決了類似的問題。我應該查看'ObjectFactory'類,使用了許多JAXBElement對象。 – zygimantus 2018-02-07 12:25:46