Apache Camel 路由到 SOAP API

Apache Camel Route to SOAP API

我正在尝试通过 Apache Camel post 一些 xml 数据到 SOAP API。请查看 Camel 路由 below.What 我在这里尝试读取 C:/input 中的 xml 文件并将其内容发送到 SOAP API 托管在我的 Tomcat (localhost:8080/myservice/soapws)。 是否可以在这里使用 Camel 的 HTTP 组件? Camel 中是否有任何其他组件可用于路由到 SOAP API。我是骆驼的新手。请帮忙

以下是我的 xsd SOAP API

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

    <xs:element name="soapRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="payloadXml" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>  
</xs:schema>

另外我定义的Camel路线如下

public class MyCamelRouter extends RouteBuilder {

@Override
public void configure() throws Exception {
    from("file:C:/input")
        .to("http:localhost:8080/myservice/soapws"));
}

是的,你可以做到。对于 SOAP,您可能还需要使用

设置 SOAPAction header 或其他内容
 from("file:C:/input")
  .setHeader("SOAPAction", constant("someNameHere"))
  .to("http:localhost:8080/myservice/soapws"));

您可以使用 SoapUI 尝试真正调用 SOAP 服务,然后从 SoapUI 中您可以看到 HTTP 请求 body / headers,然后知道要包含哪些内容工作,然后使用 Camel 的 header / body.

复制它