2016-07-14 73 views
2

我是Spring集成的新手。我正在嘗試使用Spring集成調用soap webservice。我在本地服務器http://localhost:8080/DemoWebService/tickets上部署了webservice。使用Spring集成框架的SOAP webservice調用

下面是Spring應用程序上下文xml中的配置。

<int:gateway id="systemEntry" default-request-channel="requestChannel" default-reply-channel="responseChannel" 
    service-interface="xpadro.spring.integration.ws.gateway.TicketService"/> 
<int:channel id="requestChannel"/> 
<int:channel id="responseChannel" /> 
<int-ws:outbound-gateway id="marshallingGateway" 
    request-channel="requestChannel" reply-channel="responseChannel" 
    uri="http://localhost:8080/DemoWebService/tickets" marshaller="marshaller" 
    unmarshaller="marshaller"/> 
<oxm:jaxb2-marshaller id="marshaller" contextPath="xpadro.spring.integration.ws.types" /> 

下面是作爲網關和Junit測試類書寫的接口。

public interface TicketService { 

/** 
* Entry to the messaging system. All invocations to this method will be intercepted and sent to the SI "system entry" gateway 
* 
* @param request 
*/ 
@Gateway 
public TicketResponse invoke(TicketRequest name);} 

代碼形式JUnit測試

@Test 
public void testInvocation() throws InterruptedException, ExecutionException { 
    TicketRequest request = new TicketRequest(); 
    request.setFilmId("aFilm"); 
    request.setQuantity(new BigInteger("3")); 

    TicketResponse response = service.invoke(request); 

    assertNotNull(response); 
    assertEquals("aFilm",response.getFilmId()); 
    assertEquals(new BigInteger("5"), response.getQuantity()); 
} 

但是當我運行測試,我得到以下錯誤。請幫忙。謝謝..

WARNING: Interceptor for {http://ws.mkyong.com/}tickets has thrown exception, unwinding now 
org.apache.cxf.interceptor.Fault: Message part {http://www.xpadro.spring.samples.com/tickets}ticketRequest was not recognized. (Does it exist in service WSDL?) 

此服務在SOAP UI中運行良好。

我錯過了什麼嗎?請指教。

回答

0

Message part {http://www.xpadro.spring.samples.com/tickets}ticketRequest

你真的應該比您發送到從代碼,服務和從什麼SOAP UI什麼。

看起來您在JaxB生成的域類中沒有使用正確的namespace

看起來像真的namespace必須是ws.mkyong.com

當前主題:我知道誰是xpadro :-),但您確實應該確定您與WSDL一致。