title: How to Consume Webservice SOAP Request and response contains header and body in java
body: <p>I have the WSDL file from the bank whose service we have to consume. Using Apache axis 1.4 - WSDL2JAVA, I have generated all the proxy files.</p>
  
  <p>There are 4 methods I have to call. Each method's SOAP 1.1 request and response contains a Header and body in them. In the request, the header is used to set the data to login and the body contains a object params to actually passe the parameters for my method <code>getCat</code>.  In the response, I have the <code>header_out</code>  which passes me the connection Status, ErrorCode (for authentication) and body contains something like  </p>
  
  <pre><code> &lt;GetCatResponse xmlns="WebServices"&gt;
    &lt;GetCatResult&gt;
      &lt;xsd:schema&gt;schema&lt;/xsd:schema&gt;xml&lt;/GetCatResult&gt;
  &lt;/GetCatResponse&gt;
  </code></pre>
  
  <p>Can any one tell me how I can write the client code to send the request and get the response. </p>
  
  <p>Soap looks like below.</p>
  
  <pre><code> SOAPAction: "WebServices/GetCat"
    &lt;soap:Envelope ....&gt;
     &lt;soap:Header&gt;
      &lt;ws_Header xmlns="WebServices"&gt;
       &lt;sWebUser&gt;string&lt;/sWebUser&gt;
        &lt;sWebPassword&gt;string&lt;/sWebPassword&gt;
        &lt;sCompanyID&gt;string&lt;/sCompanyID&gt;
       &lt;/ws_Header&gt;
      &lt;/soap:Header&gt;
     &lt;soap:Body&gt;
       &lt;GetCat xmlns="WebServices"&gt;
        &lt;ObjParms&gt;
         &lt;sCountry&gt;string&lt;/sCountry&gt;
         &lt;sCatType&gt;string&lt;/sCatType&gt;
         &lt;/ObjParms&gt;
       &lt;/GetCat&gt;
      &lt;/soap:Body&gt;
    &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>RESPONSE</p>
  
  <pre><code>&lt;soap:Envelope ...&gt;
  &lt;soap:Header&gt;
    &lt;ws_Header_Out xmlns="WebServices"&gt;
     &lt;sFlagStatus&gt;int&lt;/sFlagStatus&gt;
     &lt;sErrorCode&gt;string&lt;/sErrorCode&gt;
    &lt;/ws_Header_Out&gt;
  &lt;/soap:Header&gt;
  &lt;soap:Body&gt;
    &lt;GetCatResponse xmlns="WebServices"&gt;
      &lt;GetCatResult&gt;
       &lt;xsd:schema&gt;schema&lt;/xsd:schema&gt;xml&lt;/GetCatResult&gt;
     &lt;/GetCatResponse&gt;
   &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>