gpt4 book ai didi

java - 使用 Camel 通过 http 发送普通 SOAP

转载 作者:行者123 更新时间:2023-12-02 03:55:39 25 4
gpt4 key购买 nike

我正在尝试设置一个非常简单的路由来通过 http 发送 SOAP 内容,然后显示响应:

<route>
<from uri="direct:start"/>
<setBody>
<constant><![CDATA[<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"><SOAP:Header></SOAP:Header><SOAP:Body></SOAP:Body></SOAP:Envelope>]]>
</constant>
</setBody>
<to uri="https://localhost:8443/api"/>
<log message="${out.body}"/>
</route>

我没有收到任何错误,但没有真正显示响应。

我在这里缺少什么?

我只是像这样运行我的应用程序:

public class App {
public static void main( String[] args ) {
ApplicationContext
ctx = new ClassPathXmlApplicationContext("META-INF/spring/camel-config.xml");
}
}

最佳答案

您尚未设置某些 header 。

尝试如下修改您的路线:

 <route>
<from uri="timer://foo?fixedRate=true&amp;period=60000"/>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="Content-type">
<constant>text/xml;charset=UTF-8</constant>
</setHeader>
<setHeader headerName="Accept-Encoding">
<constant>gzip,deflate</constant>
</setHeader>

<setBody>
<constant><![CDATA[<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"><SOAP:Header></SOAP:Header><SOAP:Body></SOAP:Body></SOAP:Envelope>]]>
</constant>
</setBody>
<to uri="https://localhost:8443/api"/>
<log message="${out.body}"/>
</route>

我更改了路线的开头,因为我不知道您如何向 direct:start 发送消息。

关于java - 使用 Camel 通过 http 发送普通 SOAP ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35494718/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com