From: curl-library [mailto:[email protected]] On Behalf Of Ray 
Satiro via curl-library
Sent: Saturday, August 15, 2015 12:28 AM
To: libcurl development <[email protected]>
Subject: Re: CURL custom POST commands

On 8/14/2015 4:21 PM, Fitzgerald, Kevin wrote:

Hello again, I have decided to try a different tack and I am using the sendrecv 
example from the site. Everything seems to work as I need it to, but I am 
getting an Internal Server Error back from the server.
<?xml version="1.0" encoding="utf-8"?><soap:Envelope 
xmlns:soap="http://www.w3.org/2003/05/soap-envelope";<http://www.w3.org/2003/05/soap-envelope>
 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";<http://www.w3.org/2001/XMLSchema-instance>
 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";<http://www.w3.org/2001/XMLSchema>><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text
 xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable 
to process request. ---&gt; System.Xml.XmlException: Data at the root level is 
invalid. Line 1, position 1.

I think I am getting this error because of a byte-order mark (BOM) that is 
being added to the HTTP. The data being sent is correct for the web services 
request. Is there a curl option to remove this from the request when using 
culr_easy_send? Any help would be appreciated. Below is the code:
            curl = curl_easy_init();
            if(curl)
            {
              const char *request = full_msg;
              curl_socket_t sockfd; /* socket */
              long sockextr;
              size_t iolen;
              curl_off_t nread;

               printf("\n\n\nYou are using libcurl/%s\n\n\n", 
curl_version_info(CURLVERSION_NOW)->version);

               curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

               /* specify target URL */
               curl_easy_setopt(curl, CURLOPT_URL, url);

               curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);

               curl_easy_setopt(curl, CURLOPT_LOCALPORT, dcf_port);

               curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);

CURLOPT_CONNECT_ONLY is for custom protocols. I don't understand why you would 
need that option for sending a SOAP message. How is the BOM being added to the 
HTTP? Are you trying to imitate the HTTP protocol? It sounds like you are 
complicating things. Did you try sending your message via HTTPS as I suggested, 
and without disabling verification?

Hello again. It appears that I am now successfully connecting to the web 
service, but I having one issue that I don’t understand. I am using the below 
code to get the response back from the web service:
/* read the response */
               wait_on_socket(sockfd, 1, 60000L);
               res = curl_easy_recv(curl, s2, 32768, &iolen);

               if(CURLE_OK != res)
                  break;

               fprintf(stdout, "%s\n", s2);
               nread = (curl_off_t)iolen;

               printf("Received %" CURL_FORMAT_CURL_OFF_T " bytes.\n", nread);
               /* always cleanup */
               curl_easy_cleanup(curl);

s2 is a buffer to capture the response. I am displaying this buffer in my job’s 
sysout. The issue is that it appears that all of the data in the response is 
not in the buffer. Below is the displayed buffer:
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
Set-Cookie: ASP.NET_SessionId=sfmiyijxoyot1oub0sd2bb55; path=/; HttpOnly
X-Powered-By: ASP.NET
Date: Fri, 28 Aug 2015 18:14:09 GMT
Content-Length: 568

Received 919 bytes.
* Closing connection #0
The sysout says I am receiving 919 bytes from the web service. This is the same 
number of bytes I receive from the web service using a command line wgets 
sending the same data, so it appears that I am getting the expected response. 
But where is the rest of the data? It should have the following in the buffer 
as well:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:
xsd="http://www.w3.org/2001/XMLSchema";><soap:Body><checkCertificationsResponse 
xmlns="http://workweb.dwd.state.wi.us/KIDS/LicenseCertification/Service";><checkCertificat
ionsResult><LicenseCertificationStatus><ssn>395555555</ssn><firstName>LARRY</firstName><lastName>MEDICINA</lastName><middleName>A</middleName><dateOfBirth>05/15/1965</d
ateOfBirth><genderCode>M</genderCode><agencyCode>WDHF</agencyCode><licenseCategoryCode>PO</licenseCategoryCode><certified>Yes</certified><certificationReason>Delinquenc
y</certificationReason><certificationStartDate>04/07/2010</certificationStartDate><uniqueRecordIdentifier>1</uniqueRecordIdentifier></LicenseCertificationStatus></check
CertificationsResult></checkCertificationsResponse></soap:Body></soap:Envelope>

Am I doing something wrong in my use of curl_easy_recv? From the description on 
the curl website, what I am doing looks correct, but then where is the data?

Thank you,

Kevin
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to