title: How to send Soap request to webservice
body: <p>I am new to Soap ,</p>
  
  <p>With the help of SOAPUI i am sending   </p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"&gt;
  &lt;SOAP-ENV:Header/&gt;
  &lt;soapenv:Body&gt;
    &lt;tem:RequestData&gt;
       &lt;tem:requestDocument&gt;
       &lt;![CDATA[
       &lt;Request&gt;
         &lt;Authentication CMId="68" Function="1" Guid="5594FB83-F4D4-431F-B3C5-EA6D7A8BA795" Password="poihg321TR"/&gt;
         &lt;Establishment Id="4297867"/&gt;
      &lt;/Request&gt;
      ]]&gt;
      &lt;/tem:requestDocument&gt;
    &lt;/tem:RequestData&gt;
   &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;  
  </code></pre>
  
  <p>The response from SOAPUI is   </p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;s:Body&gt;
    &lt;RequestDataResponse xmlns="http://tempuri.org/"&gt;
       &lt;RequestDataResult&gt;&lt;![CDATA[&lt;Response&gt;
   &lt;Authentication CMId="68" Function="1" Guid="5594FB83-F4D4-431F-B3C5-EA6D7A8BA795" Password="poihg321TR" /&gt;
   &lt;Establishment Id="4297867"&gt;
    &lt;RoomTypes&gt;
    &lt;RoomType RoomTypeId="1040459" Description="Double Room" /&gt;
    &lt;RoomType RoomTypeId="1040458" Description="Single Room" /&gt;
  &lt;/RoomTypes&gt;
    &lt;BoardTypes&gt;
     &lt;BoardType BoardTypeId="1" Description="Room Only" /&gt;
    &lt;/BoardTypes&gt;
  &lt;/Establishment&gt;
  &lt;/Response&gt;]]&gt;&lt;/RequestDataResult&gt;
    &lt;/RequestDataResponse&gt;
   &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;  
  </code></pre>
  
  <p>Now i have written a Java code   </p>
  
  <pre><code>            MessageFactory mf = MessageFactory.newInstance();
          SOAPMessage sm = mf.createMessage();
          SOAPEnvelope envelope = sm.getSOAPPart().getEnvelope();
          envelope.addNamespaceDeclaration("soap", "http://schemas.xmlsoap.org/soap/envelope/");
          envelope.setPrefix("soapenv");
  
          envelope.setAttribute("xmlns:tem", "http://tempuri.org/");
  
          SOAPBody body = envelope.getBody();
          body.setPrefix("soapenv");
  
          SOAPElement requestData = body.addChildElement("RequestData");
          requestData.setPrefix("tem");
  
          SOAPElement requestDoc = requestData.addChildElement("requestDocument", "tem", "http://tempuri.org/");
  
  
  
          CDATASection cdata = requestDoc.getOwnerDocument().createCDATASection("&lt;Request&gt;\n"
                  + "           &lt;Authentication CMId=\"68\" Function=\"1\" Guid=\"5594FB83-F4D4-431F-B3C5-EA6D7A8BA795\" Password=\"poihg321TR\"/&gt;\n"
                  + "           &lt;Establishment Id=\"4297867\"/&gt;\n"
                  + "        &lt;/Request&gt;");
          requestDoc.appendChild(cdata);
          sm.writeTo(System.out);
  
  
          SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance();
          SOAPConnection connection = sfc.createConnection();
          URL requestUrl = new URL("http://pp.hotels.travelrepublic.co.uk/ChannelManager.svc?wsdl");
          SOAPMessage response = connection.call(sm, requestUrl);
          System.out.println("");
          System.out.println("***************");
          response.writeTo(System.out);
  </code></pre>
  
  <p>The request sending from java code is (same as request sent by soap ui)   </p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"&gt;&lt;SOAP-ENV:Header/&gt;&lt;soapenv:Body&gt;&lt;tem:RequestData&gt;&lt;tem:requestDocument xmlns:tem="http://tempuri.org/"&gt;&lt;![CDATA[&lt;Request&gt;
         &lt;Authentication CMId="68" Function="1" Guid="5594FB83-F4D4-431F-B3C5-EA6D7A8BA795" Password="poihg321TR"/&gt;&lt;Establishment Id="4297867"/&gt;
      &lt;/Request&gt;]]&gt;&lt;/tem:requestDocument&gt;&lt;/tem:RequestData&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;    
  </code></pre>
  
  <p>But response i am getting is   </p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;s:Body&gt;&lt;s:Fault&gt;&lt;faultcode xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;a:ActionNotSupported&lt;/faultcode&gt;&lt;faultstring xml:lang="en-GB"&gt;The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).&lt;/faultstring&gt;&lt;/s:Fault&gt;&lt;/s:Body&gt;&lt;/s:Envelope&gt;
  </code></pre>
  
  <p>Please help i am new to webservices </p>