title: Cant able to receive response from Web service using curl from C++
body: <p>I am trying to get response from web service using curl and c++. I have tried calling the web service from terminal. It works fine I can receive the response. </p>
  
  <p>But I cannot able to reproduce the same through c++. </p>
  
  <pre><code> Request.xml
  &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:blz="http://thomas-bayer.com/blz/“&gt;
   &lt;soapenv:Header/&gt;
    &lt;soapenv:Body&gt;
     &lt;blz:getBank&gt;
        &lt;blz:blz&gt;50070010&lt;/blz:blz&gt;
      &lt;/blz:getBank&gt;
    &lt;/soapenv:Body&gt;
   &lt;/soapenv:Envelope&gt;
  
  
  void dataFromWebService :: connectWithWebservice(){    
  
  struct curl_slist *header = NULL;
  header = curl_slist_append (header, "Content-Type:text/xml");
  header = curl_slist_append (header, "charset=UTF-8");
  header = curl_slist_append (header, "SOAPAction:urn:getBank");
  
  curl = curl_easy_init();    
  
  if(curl == NULL){
  
      cout&lt;&lt;"CURL is NULL";
  }
  
  const char *myUrl = "http://www.thomas-bayer.com/axis2/services/BLZService";
  
  //const char *myUrl = "http://11.22.33.231:9080/VehicleInfoQueryService.asm";
  if(curl){
  
      string Mydata;
  
      char errbuf[CURL_ERROR_SIZE];
      struct MemoryStruct chunk;
  
      chunk.memory = (char*)malloc(1);  /* will be grown as needed by the realloc above */
      chunk.size = 0;    /* no data at this point */
  
  
      FILE * rfp = fopen("request.xml", "r");
  
      curl_easy_setopt(curl, CURLOPT_URL, myUrl);
  
      //curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
      curl_easy_setopt(curl, CURLOPT_READDATA, rfp);
      curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header);
  
      curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
      curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION, 1);
      curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
  
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
  
       char *response = NULL;
      /* passing the pointer to the response as the callback parameter */
      curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&amp;chunk);
  
  
  
      errbuf[0] = 0;
      cout&lt;&lt; "The result from webservice "&lt;&lt;endl;
  
      /* Perform the request, res will get the return code */
  
      curlCode = curl_easy_perform(curl);
  
      /* send all data to this function  */
  
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
  
      curl_easy_setopt(curl,CURLOPT_WRITEDATA,(void *)&amp;chunk);
  
  
      cout &lt;&lt;"curl code-- "&lt;&lt;curlCode&lt;&lt;endl;
  
  
      //  always cleanup
      if(curlCode != CURLE_OK  | curlCode != 0) {
          size_t len = strlen(errbuf);
          fprintf(stderr, "\nlibcurl: (%d) ", curlCode);
          if(len)
              fprintf(stderr, "%s%s", errbuf,
                      ((errbuf[len - 1] != '\n') ? "\n" : ""));
          else
              fprintf(stderr, "%s\n", curl_easy_strerror(curlCode));
      } else {
          /*
           * Now, our chunk.memory points to a memory block that is chunk.size
           * bytes big and contains the remote file.
           */
  
          printf("%lu bytes retrieved\n", (long)chunk.size);
  
          cout&lt;&lt;"My Chunck -- "&lt;&lt;chunk.memory&lt;&lt;endl;
      }
      curl_easy_cleanup(curl);
  
  }
  
  } 
  </code></pre>
  
  <p>output from code: </p>
  
  <pre><code>The result from webservice 
  *   Trying 80.152.243.114...
  * Connected to www.thomas-bayer.com (80.152.243.114) port 80 (#0)
  &gt; GET /axis2/services/BLZService HTTP/1.1
  Host: www.thomas-bayer.com
  Accept: */*
  Content-Type:text/xml
  SOAPAction:urn:getBank
  
  &lt; HTTP/1.1 500 Internal Server Error
  &lt; Server: Apache-Coyote/1.1
  &lt; Content-Type: application/xml;charset=UTF-8
  &lt; Date: Fri, 02 Dec 2016 10:56:36 GMT
  &lt; Connection: close
  &lt; Content-Length: 2388
  &lt; 
  * Closing connection 0
  curl code-- 0
  2388 bytes retrieved
  My Chunck -- &lt;?xml version="1.0" ?&gt;&lt;Exception&gt;org.apache.axis2.AxisFault: The endpoint reference (EPR) for the Operation not found is /axis2/services/BLZService and the WSA Action = null
      at org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:86)
      at org.apache.axis2.engine.Phase.invoke(Phase.java:308)
      at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:212)
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:132)
      at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:125)
      at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:119)
      at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:799)
      at org.apache.axis2.transport.http.AxisServlet.doGet(AxisServlet.java:242)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:745)
  &lt;/Exception&gt;
  Hello, World!
  </code></pre>
  
  <p>From terminal: </p>
  
  <p>command:</p>
  
  <pre><code>curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:urn:getBank" --data @request.xml http://www.thomas-bayer.com/axis2/services/BLZService
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code> &lt;?xml version='1.0' encoding='UTF-8’?&gt;
   &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/“&gt;
    &lt;soapenv:Body&gt;  
       &lt;ns1:getBankResponse xmlns:ns1="http://thomas-bayer.com/blz/“&gt;
          &lt;ns1:details&gt;
                &lt;ns1:bezeichnung&gt;
                     Deutsche Bank Filiale
                &lt;/ns1:bezeichnung&gt;
         &lt;ns1:bic&gt;
                 DEUTDEFFXXX
         &lt;/ns1:bic&gt;
         &lt;ns1:ort&gt;
                 Frankfurt am Main
         &lt;/ns1:ort&gt; 
         &lt;ns1:plz&gt;
                 60254
         &lt;/ns1:plz&gt;
        &lt;/ns1:details&gt;
      &lt;/ns1:getBankResponse&gt;
     &lt;/soapenv:Body&gt;
   &lt;/soapenv:Envelope&gt;
  </code></pre>