我有基于 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
这是通过 Camel 调用肥皂服务的正确方法吗?
依赖关系
<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>
最佳答案
以下是使用 cxf
时我的 SOAP WS 示例的外观。
首先,在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>
现在 Camel 路线如下所示:
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>
关于java - 使用 Apache Camel 和 spring-ws 组件调用基于 SOAP 的服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50504349/