简体   繁体   中英

Apache Camel Route to SOAP API

I'm trying to post some xml data to a SOAP API through Apache Camel. Please see the Camel route below.What I'm trying here is to read an xml file in C:/input and send its content to a SOAP API hosted at my Tomcat (localhost:8080/myservice/soapws). Is it possible to use Camel's HTTP component here? Is there any other component in Camel that can be used for routing to SOAP API. I'm new to Camel. Please help

Following is my xsd for the 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>

Also the Camel route I defined is as follows

public class MyCamelRouter extends RouteBuilder {

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

Yes you can do that. For SOAP you may need to set the SOAPAction header or something as well, using

 from("file:C:/input")
  .setHeader("SOAPAction", constant("someNameHere"))
  .to("http:localhost:8080/myservice/soapws"));

You can use SoapUI to try calling the SOAP service for real, and then from SoapUI you can see the HTTP request body / headers, and then know what to include for it to work, and then replicate that using Camel's header / body.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM