【发布时间】:2016-07-29 15:52:08
【问题描述】:
我正在开发向远程 Web 服务发送 SOAP 请求并使用 apache Camel 获得响应。
在这种情况下,我使用cxf-codegen-plugin 为下面提到的 WSDl 成功生成了客户端 wsdl2java 代码。
- 示例 WSDL URL:
http://www.webservicex.net/stockquote.asmx?WSDL
在做了一些研究之后,我创建了下面的示例代码,以向其中定义的 Web 服务发送 SOAP 请求,并使用生成的客户端代码通过 apache Camel 获得响应。
CamelContext context = new DefaultCamelContext();
HttpComponent httpComponent = new HttpComponent();
context.addComponent("http", httpComponent);
ProducerTemplate template = context.createProducerTemplate();
GetQuote getQuote = new GetQuote();
getQuote.setSymbol("test123");
GetQuoteResponse getQuoteResponse = template.requestBody("http://www.webservicex.net/stockquote.asmx",getQuote, GetQuoteResponse.class);
System.out.println(getQuoteResponse);
但它给出了以下错误。
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: net.webservicex.GetQuote@10bdf5e5 of type: net.webservicex.GetQuote on: Message[ID-namal-PC-33172-1469806939935-0-1]. Caused by: No type converter available to convert from type: net.webservicex.GetQuote to the required type: java.io.InputStream with value net.webservicex.GetQuote@10bdf5e5. Exchange[ID-namal-PC-33172-1469806939935-0-2]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: net.webservicex.GetQuote to the required type: java.io.InputStream with value net.webservicex.GetQuote@10bdf5e5]
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: net.webservicex.GetQuote to the required type: java.io.InputStream with value net.webservicex.GetQuote@10bdf5e5
我错过了什么?数据绑定?还是别的什么?我使用 cxf 生成了客户端代码,那么如何使用 cxf 发送它?
我只想向远程 Web 服务发送 SOAP 请求并使用 apache Camel 获得响应。
- 骆驼版:2.9.0
- Java 版本:1.7.x / 1.8.x
【问题讨论】:
标签: java web-services soap wsdl apache-camel