【问题标题】:SOAP webservice call using Spring integration framework使用 Spring 集成框架的 SOAP Web 服务调用
【发布时间】:2016-07-14 13:17:35
【问题描述】:

我是 Spring 集成的新手。我正在尝试使用 Spring 集成调用soap webservice。我在本地服务器http://localhost:8080/DemoWebService/tickets 上部署了网络服务。

下面是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 中运行良好。

我在这里遗漏了什么吗?请指教。

【问题讨论】:

    标签: spring spring-integration


    【解决方案1】:

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

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

    看起来您在 JaxB 生成的域类中没有使用正确的 namespace

    看起来真实的namespace一定是ws.mkyong.com

    题外话:我知道谁是xpadro :-),但您确实应该确保您与 WSDL 保持一致。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-20
      • 1970-01-01
      • 1970-01-01
      • 2017-01-12
      • 2019-02-25
      • 2012-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多