簡體   English   中英

使用apache駱駝將數據從隊列傳輸到soap服務器

[英]data transfer from the queue to the soap server using apache camel

我在隊列中有一個JSON: {"user":'Alex', "times": 34} 我想從此數據發送肥皂請求到服務器

WSDL:

WSDL

我的路線:

<route>
    <from uri="rabbitmq://10.0.62.201/exchange1?queue=from-lanbilling" />
    <to uri="cxf://http://0.0.0.0:8000?wsdlURL=http://localhost:8000/?wsdl" />
    <log message="message ${body}" />
</route>

我如何從隊列中轉換JSON數據以進行肥皂請求?

UPDATE

我不得不將camel-http與強制的soap-string xml一起使用:

藍圖:

<camelContext
    xmlns="http://camel.apache.org/schema/blueprint">

    <route>
        <from uri="rabbitmq://10.0.62.201/exchange1?queue=from-lanbilling" />
            <process ref="jTos" />      
            <log message="message ${body}" />
        <!--  <to uri="cxf://http://0.0.0.0:8000?dataFormat=PAYLOAD" />  -->
                    <setHeader headerName="Content-Type">
            <constant>application/xml; charset=utf-8</constant>
        </setHeader>
        <to uri="http://0.0.0.0:8000"/>
        <log message="message ${body}" />
    </route>


</camelContext>

JsonToSoap:

public class JsonToSoap implements Processor {

public void process(Exchange exchange) throws Exception {

    String json = exchange.getIn().getBody(String.class);
    JSONObject obj = new JSONObject(json);

    String name = obj.getString("name");
    Integer timer = obj.getInt("timer");

    String soap_xml = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:spy=\"spyne.examples.hello\">\r\n" + 
            "   <soapenv:Header/>\r\n" + 
            "   <soapenv:Body>\r\n" + 
            "      <spy:say_hello>\r\n" + 
            "         <spy:name>" + name +"</spy:name>\r\n" + 
            "         <spy:times>" + timer + "</spy:times>\r\n" + 
            "      </spy:say_hello>\r\n" + 
            "   </soapenv:Body>\r\n" + 
            "</soapenv:Envelope>";


    exchange.getOut().setBody(soap_xml);


}
}

我如何僅通過camel-cxf做同樣的事情? 我認為有一個更優雅的解決方案。

看看AtlasMap! https://atlasmap.io )它具有駱駝組件。 它支持在XML,JSON和Java對象之間來回轉換數據。

免責聲明:我創建了AtlasMap

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM