【问题标题】:How to save soap play to file in apache camel?如何将肥皂剧保存到 apache camel 中的文件?
【发布时间】:2018-09-15 06:04:10
【问题描述】:

尝试通过下面的代码将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 个常用帧

【问题讨论】:

    标签: apache-camel


    【解决方案1】:

    它适用于以下代码

            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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多