试图通过下面的代码将soap
请求(jaxb有效载荷)保存为apache camel中的xml
有效载荷,但失败了。
谁知道怎么做?
任何提示都将非常受欢迎!
码:
public class CamelRouteBuilder extends RouteBuilder {
private static final String SOAP_ENDPOINT_URI = "cxf://http://localhost:{{soapEndpointPort}}/soap" +
"?serviceClass=org.yw.springbootcamelesb.soap.CreateFileService";
@Override
public void configure() throws Exception {
from(SOAP_ENDPOINT_URI).process(new CreateFileProcessor()).to("file:target/reports");;
}
}
我得到的例外情况如下
pringbootcamelesb.soap.FileCreationStatus on:消息[ID-YandeMBP-1536989276152-2-2]。引发者:没有类型转换器可以从类型:org.yw.springbootcamelesb.soap.FileCreationStatus转换为所需类型:java.io.InputStream,其值为org.yw.springbootcamelesb.soap.FileCreationStatus@75ec37c5。交换[ID-YandeMBP-1536989276152-2-1]。引起:[org.apache.camel.NoTypeConversionAvailableException - 没有类型转换器可用于从类型:org.yw.springbootcamelesb.soap.FileCreationStatus转换为所需类型:java.io.InputStream,其值为org.yw.springbootcamelesb.soap。 FileCreationStatus @ 75ec37c5]在org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:117)〜[camel-core-2.22.0.jar:2.22.0] org.apache.camel.component.file。 FileOperations.storeFile(FileOperations.java:333)〜[camel-core-2.22.0.jar:2.22.0] ...省略了40个常用帧
它适用于以下代码
JaxbDataFormat xmlDataFormat = new JaxbDataFormat();
JAXBContext con = JAXBContext.newInstance(FileCreationStatus.class);
xmlDataFormat.setContext(con);
from(SOAP_ENDPOINT_URI).process(new CreateFileProcessor())
.marshal(xmlDataFormat).to("file:target/output").unmarshal(xmlDataFormat);