使用Spring集成框架

时间:2016-07-14 13:17:36

标签: spring spring-integration

我是Spring集成的新手。我试图使用Spring集成调用soap webservice。我在本地服务器http://localhost:8080/DemoWebService/tickets上部署了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中运行良好。

我在这里错过了什么吗?请指教。

1 个答案:

答案 0 :(得分:0)

  

pause

您应该真正比较从代码发送到该服务的内容以及来自SOAP UI的内容。

看起来您没有在JaxB生成的域类中使用正确的Message part {http://www.xpadro.spring.samples.com/tickets}ticketRequest

真实的namespace看起来必须是namespace

超出主题:我知道谁是ws.mkyong.com :-),但你确实应该确定你与WSDL一致。