title: Generate soap request using Camel
body: <p>I want to call third party webservice from camel using wsdl file without any generating client code(because i think if i am providing wsdl file then camel able to generate client that we previously generate and that's working in our older code)</p>
  
  <p>After searching long time i found some code that helps me to achieve my goal</p>
  
  <p>code is</p>
  
  <pre><code>import org.apache.camel.CamelContext;
  import org.apache.camel.Exchange;
  import org.apache.camel.Processor;
  import org.apache.camel.ProducerTemplate;
  import org.apache.camel.dataformat.soap.Soap11DataFormatAdapter;
  import org.apache.camel.dataformat.soap.Soap12DataFormatAdapter;
  import org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy;
  import org.apache.camel.impl.DefaultCamelContext;
  import org.apache.camel.model.dataformat.SoapJaxbDataFormat;
  
  import com.camel.model.Application;
  public class TestMain {
      static CamelContext context;
  
      public static void main(String args[]) throws Exception {
          CamelContext context = new DefaultCamelContext();
          ProducerTemplate template = context.createProducerTemplate(0);
          context.start();
          String url="cxf://http://localhost:8081/buzzor-service/services/ApplicationService?" +
            "wsdlURL=http://localhost:8081/buzzor-service/services/ApplicationService?wsdl&amp;" +
            "serviceName={http://service.application.buzzor.atpl.com}ApplicationService&amp;" +
            "portName={http://service.application.buzzor.atpl.com}ApplicationServiceHttpPort&amp;" +
            "dataFormat=MESSAGE";
          Exchange reply = sendSimpleMessage(template, url);
          org.apache.camel.Message out = reply.getOut();
          String result = out.getBody(String.class);
  
          System.out.println(result);
          Thread.sleep(10000);
          context.stop();
      }
  
      private static Exchange sendSimpleMessage(ProducerTemplate template,
              String endpointUri) {
  
  
          Exchange exchange = template.request(endpointUri, new Processor() {
              public void process(final Exchange exchange) throws Exception {
  
                  exchange.getIn().setBody("&lt;soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;"
                           + "&lt;soap:Body&gt;&lt;ns1:getApplication xmlns:ns1=\"http://cxf.component.camel.apache.org/\"&gt;"
  //                         + "&lt;arg0 xmlns=\"http://cxf.component.camel.apache.org/\"&gt;hello world&lt;/arg0&gt;"
                           + "&lt;/ns1:getApplication&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;");
  
  
                   System.out.println(exchange.getIn().getBody());
              }
          });
          return exchange;
      }
  }
  </code></pre>
  
  <p>this works correctly but here i am manually generate soap Envelop</p>
  
  <p>wsdl file is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;wsdl:definitions targetNamespace="http://service.application.buzzor.atpl.com" xmlns:ns1="urn:http://model.application.buzzor.atpl.com" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://service.application.buzzor.atpl.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
    &lt;wsdl:types&gt;
  &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://service.application.buzzor.atpl.com"&gt;
  &lt;xsd:element name="getApplication"&gt;
  &lt;xsd:complexType/&gt;
  &lt;/xsd:element&gt;
  &lt;xsd:element name="getApplicationResponse"&gt;
  &lt;xsd:complexType&gt;
  &lt;xsd:sequence&gt;
  &lt;xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/&gt;
  &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
  &lt;xsd:element name="addApplication"&gt;
  &lt;xsd:complexType&gt;
  &lt;xsd:sequence&gt;
  &lt;xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="ns1:Application"/&gt;
  &lt;xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="ns1:User"/&gt;
  &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
  &lt;xsd:element name="addApplicationResponse"&gt;
  &lt;xsd:complexType&gt;
  &lt;xsd:sequence&gt;
  &lt;xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="ns1:ApplicationResult"/&gt;
  &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;/xsd:element&gt;
  &lt;/xsd:schema&gt;
  &lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:http://model.application.buzzor.atpl.com"&gt;
  &lt;xsd:complexType name="Application"&gt;
  &lt;xsd:sequence&gt;
  &lt;xsd:element minOccurs="0" name="APP_ID" nillable="true" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="APP_NAME" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="APP_PASSWORD" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="APP_TYPE" nillable="true" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="APP_VERSION" nillable="true" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="EXCEPTION_HANDLED" nillable="true" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="IS_LOGIN_REQUIRED" nillable="true" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="LONG_CODES" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="PREVIOUS_NODE_KEY" nillable="true" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="REPLY_TEXT" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="WELCOME_NOTE" nillable="true" type="xsd:string"/&gt;
  &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;xsd:complexType name="User"&gt;
  &lt;xsd:sequence&gt;
  &lt;xsd:element minOccurs="0" name="ACTIVE_STATUS" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="CUSTOMER_ID" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="FIRST_NAME" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="IS_ADMIN" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="LAST_NAME" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="LOGIN_USER_ID" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="LOGIN_ALLSC" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="USER_ACTION" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="USER_CONFIRM_PASSWORD" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="USER_ID" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="USER_PASSWORD" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="USER_PATH" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="USER_STATUS" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="USER_TYPE" type="xsd:boolean"/&gt;
  &lt;xsd:element minOccurs="0" name="VERSION_ID" type="xsd:double"/&gt;
  &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;xsd:complexType name="ApplicationResult"&gt;
  &lt;xsd:sequence&gt;
  &lt;xsd:element minOccurs="0" name="APP_ID" nillable="true" type="xsd:int"/&gt;
  &lt;xsd:element minOccurs="0" name="APP_NAME" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="ERROR_MESSAGE" nillable="true" type="xsd:string"/&gt;
  &lt;xsd:element minOccurs="0" name="ERROR_STATUS" nillable="true" type="xsd:int"/&gt;
  &lt;/xsd:sequence&gt;
  &lt;/xsd:complexType&gt;
  &lt;/xsd:schema&gt;
    &lt;/wsdl:types&gt;
    &lt;wsdl:message name="addApplicationRequest"&gt;
      &lt;wsdl:part name="parameters" element="tns:addApplication"&gt;
      &lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
    &lt;wsdl:message name="addApplicationResponse"&gt;
      &lt;wsdl:part name="parameters" element="tns:addApplicationResponse"&gt;
      &lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
    &lt;wsdl:message name="getApplicationResponse"&gt;
      &lt;wsdl:part name="parameters" element="tns:getApplicationResponse"&gt;
      &lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
    &lt;wsdl:message name="getApplicationRequest"&gt;
      &lt;wsdl:part name="parameters" element="tns:getApplication"&gt;
      &lt;/wsdl:part&gt;
    &lt;/wsdl:message&gt;
    &lt;wsdl:portType name="ApplicationServicePortType"&gt;
      &lt;wsdl:operation name="getApplication"&gt;
        &lt;wsdl:input name="getApplicationRequest" message="tns:getApplicationRequest"&gt;
      &lt;/wsdl:input&gt;
        &lt;wsdl:output name="getApplicationResponse" message="tns:getApplicationResponse"&gt;
      &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="addApplication"&gt;
        &lt;wsdl:input name="addApplicationRequest" message="tns:addApplicationRequest"&gt;
      &lt;/wsdl:input&gt;
        &lt;wsdl:output name="addApplicationResponse" message="tns:addApplicationResponse"&gt;
      &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
    &lt;/wsdl:portType&gt;
    &lt;wsdl:binding name="ApplicationServiceHttpBinding" type="tns:ApplicationServicePortType"&gt;
      &lt;wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
      &lt;wsdl:operation name="getApplication"&gt;
        &lt;wsdlsoap:operation soapAction=""/&gt;
        &lt;wsdl:input name="getApplicationRequest"&gt;
          &lt;wsdlsoap:body use="literal"/&gt;
        &lt;/wsdl:input&gt;
        &lt;wsdl:output name="getApplicationResponse"&gt;
          &lt;wsdlsoap:body use="literal"/&gt;
        &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
      &lt;wsdl:operation name="addApplication"&gt;
        &lt;wsdlsoap:operation soapAction=""/&gt;
        &lt;wsdl:input name="addApplicationRequest"&gt;
          &lt;wsdlsoap:body use="literal"/&gt;
        &lt;/wsdl:input&gt;
        &lt;wsdl:output name="addApplicationResponse"&gt;
          &lt;wsdlsoap:body use="literal"/&gt;
        &lt;/wsdl:output&gt;
      &lt;/wsdl:operation&gt;
    &lt;/wsdl:binding&gt;
    &lt;wsdl:service name="ApplicationService"&gt;
      &lt;wsdl:port name="ApplicationServiceHttpPort" binding="tns:ApplicationServiceHttpBinding"&gt;
        &lt;wsdlsoap:address location="http://localhost:8081/buzzor-service/services/ApplicationService"/&gt;
      &lt;/wsdl:port&gt;
    &lt;/wsdl:service&gt;
  &lt;/wsdl:definitions&gt;
  </code></pre>
  
  <p>now i want to generate soap request rather that static</p>
  
  <p>please help me </p>
  
  <p>Thanks in advance</p>