cURL / Mailing Lists / curl-library / Single Mail

curl-library

ĦI need help please!

From: Gonzalo Astuy <gac.irdb_at_glarcam.com>
Date: Tue, 12 Apr 2005 11:04:43 +0200

I have an aplicattion that send a xml file to a server; the problem
which I have this server I must specify to him that the content is
text/xml, can I do it?
 
I put you the code part of the aplicattion that make the conexion and
send the xml.
 
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------

---
string sendALNZ(string xmlReq, string url, string cert, string key)
{
  string xmlResp = "";
  string postData = xmlReq; //xmlReg is the xml file
  const char *ch_xmlReq = postData.data();
  const char *ch_URL = url.data();
  const char *ch_CERT = cert.data();
  const char *ch_KEY = key.data();
 
  CURL *curl_handle;
  CURLcode resp;
 
  struct MemoryStruct tempbuffer;
  tempbuffer.memory=NULL; // INIT Expect realloc(NULL, size) to work
  tempbuffer.size = 0;    // INIT no data at this point
 
  //INIT CURL
  curl_global_init(CURL_GLOBAL_ALL);
  curl_handle = curl_easy_init();
 
  if(curl_handle)
  {
    curl_easy_setopt(curl_handle, CURLOPT_URL, ch_URL);
 
    // MEM USE
    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION,
WriteMemoryCallback);
    //! Pass 'tempbuffer' struct to the callback function 
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void
*)&tempbuffer);
    curl_easy_setopt(curl_handle, CURLOPT_USERAGENT,
"libcurl-agent/1.0");
    curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, ch_xmlReq);
      // Conexión con certificado
      curl_easy_setopt(curl_handle, CURLOPT_SSLCERTTYPE, "PEM");
    curl_easy_setopt(curl_handle, CURLOPT_SSLCERT, ch_CERT);
      curl_easy_setopt(curl_handle, CURLOPT_SSLKEYTYPE, "PEM");
    curl_easy_setopt(curl_handle, CURLOPT_SSLKEY, ch_KEY);
    //curl_easy_setopt(curl_handle, CURLOPT_CAINFO, "cacerts");
      curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, FALSE);
 
      resp = curl_easy_perform(curl_handle);
    curl_easy_cleanup(curl_handle);
 
    for(int index = 0; index < tempbuffer.size; index++)
    {    xmlResp += tempbuffer.memory[index];}
    delete(tempbuffer.memory);
  }
return xmlResp;
}
 
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
---
 
the server response me this:
 
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
---
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Protocol</faultcode>
<faultstring>Unsupported content type
&quot;application/x-www-form-urlencoded&quot;, must be:
&quot;text/xml&quot;.</faultstring>
<faultactor>/drsw00/servlet/rpcrouter</faultactor>
</SOAP-ENV:Fault>
 
 
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
---
 
Can you help me?
 
 
Regards.
Gonzalo Astuy
Received on 2005-04-12