0

我有基于 SOAP 的服务,它接受一些预定义的请求对象,

例如,AccountRequest 有一些字段。

示例代码

from("direct:test")
    .routeId("account.get")
    .process(exchange -> {
        exchange.getIn().setBody(createAccountRequest());
    })
    .to("spring-ws:http://localhost:8090/AccountServices/AccountOverviewService")
    .log("Got Request for account-detail");
}

上面的代码抛出错误

org.apache.camel.NoTypeConversionAvailableException: 
No type converter available to convert from type: 
com.test.AccountRequest to the required type: 
javax.xml.transform.Source with value com.test.AccountRequest@4e1c1763

这是通过骆驼调用肥皂服务的正确方法吗?

依赖项

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-boot-starter</artifactId>
    <version>2.18.3</version>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring-ws</artifactId>
    <version>2.18.3</version>
</dependency>
4

2 回答 2

2

这是我的 SOAP WS 示例使用cxf.

首先,在 中camel-context.xml,定义 Web 服务 bean:

<cxf:cxfEndpoint id="insuranceService"
                 address="http://localhost:8080/insuranceService"
                 serviceClass="com.mycompany.insurance.insurancePort"
                 wsdlURL="schema/InsuranceService.wsdl">
</cxf:cxfEndpoint>

现在骆驼路线是这样的:

from("somewhere")
    .to("cxf:bean:insuranceService")

您可能需要一些这样的依赖项:

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-cxf</artifactId>
        <version>${framework.camel}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>${framework.cxf}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-http</artifactId>
        <version>${framework.camel}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jaxb</artifactId>
        <version>${framework.camel}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-soap</artifactId>
        <version>${framework.camel}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-saxon</artifactId>
        <version>${framework.camel}</version>
    </dependency>
于 2018-05-24T08:47:36.917 回答
1

您需要通过添加将“com.test.AccountRequest”编组到 xml

  JaxbDataFormat jaxb = new JaxbDataFormat(false); //add
  jaxb.setContextPath("com.accountservice.model"); //add - path to your generated stubs

    from("direct:test")
        .routeId("account.get")
        .process(exchange -> {
            exchange.getIn().setBody(createAccountRequest());
        })
        .marshal(jaxb) //add
        .to("spring-ws:http://localhost:8090/AccountServices/AccountOverviewService")
        .log("Got Request for account-detail");
    }
于 2018-05-29T15:56:35.523 回答