利用した
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
と
size_t write_data(void *ptr, size_t size, size_t count, void *stream)
{
printf("%*.*s", size * count, size * count, ptr);
}
以下の出力を取得するには、本文コンテンツのみを取得する必要があります
* About to connect() to 10.10.1.112 port 8081 (#0)
* Trying 10.10.1.112... * connected
* Connected to 10.10.1.112 (10.10.1.112) port 8081 (#0)
> POST /iit_mobile/services/application?wsdl HTTP/1.1
Host: 10.10.1.112:8081
Accept: */*
Content-type:application/soap+xml; charset=utf-8; action="http://wsdlclass.wsdlcreat.sims.test.com/userloginMethod"
Content-Length: 629
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: application/soap+xml;charset=utf-8
< Transfer-Encoding: chunked
< Date: Tue, 11 Jun 2013 13:22:35 GMT
<
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 338 0 338 0 0 36 0 --:--:-- 0:00:09 --:--:-- 0* Connection #0 to host 10.10.1.112 left intact
* Closing connection #0
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><userloginMethodResponse xmlns="http://wsdlclass.wsdlcreat.sims.test.com"/></soapenv:Body></soapenv:Envelope>
コード:
curl = curl_easy_init();
if(curl)
{
out_fd = fopen (filename, "w");
curl_easy_setopt(curl, CURLOPT_FILE, out_fd);
headers = curl_slist_append(headers, "Content-type:application/soap+xml; charset=utf-8; action=\"http://wsdlclass.wsdlcreat.sims.test.com/login\"");
curl_easy_setopt(curl, CURLOPT_URL, tmpbuff);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, buffer_size);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, buffer);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, Timeout);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER,errmsg);
printf("The Server%s:Performing Transaction.....\n",__func__);
res = curl_easy_perform(curl);
printf("res=after culreasey perform%d\n",res);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
fclose(out_fd);
}