CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Posts
    32

    how to i post XML to SOAP server

    I have a XML document i want to pass to my Soap server. I am using cURL. But all i get in return is "1"

    I need to get back the XML generated by the server. How do i do this? here is my cURL so far
    PHP Code:
    $ch curl_init();
       
    curl_setopt($chCURLOPT_URL$postUrl); 
       
    curl_setopt($chCURLOPT_POST);
       
    curl_setopt($chCURLOPT_POSTFIELDSclient_info($urlSetting$sSoapAction$username$password$partnerId$productId$ratePlanId$responseGroups$zipcode));
       
    curl_setopt($chCURLOPT_FOLLOWLOCATION1); // process page
       
    curl_setopt($chCURLOPT_HEADER1);
       
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
       
    $postResult curl_exec($ch);

       if (
    curl_errno($ch)) {
           print 
    curl_error($ch);
       }
       
    curl_close($ch);
       echo 
    $postResult
    What i get back is:
    HTTP/1.1 100 Continue HTTP/1.1 400 Bad Request Date: Tue, 06 Jun 2006 14:18:14 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 1.1.4322 Transfer-Encoding: chunked Cache-Control: private Content-Type: text/html
    Do i need to store a cookie with the header info?

    I think i am using POSTFIELDS wrong because that is just the generated XML and not a query string.

    How do i pass XML to a service in cURL?

    Arg... this is my last step and i can't get it, any help is much appreciated!!!

  2. #2
    Join Date
    Nov 2005
    Posts
    32

    Re: how to i post XML to SOAP server

    well i just added a header to before the XML and i got through. Now only if IT would get there **** servers working and it would stop sending a .NET error. I hate .NET!

  3. #3
    Join Date
    Nov 2005
    Posts
    32

    Re: how to i post XML to SOAP server

    i am posting this for people if they ever need the answer.

    to rewrite the header in cURL add this:
    PHP Code:
    // $header must be an array of values you want to add to the header
    // in my case i needed to add the SOAPAction attribute to my header

    $header = array('SOAPAction: "domain-com:2006:03:catalog/GetDeviceDetails"');
    $ch curl_init();
    // add the header element
       
    curl_setopt($chCURLOPT_HTTPHEADER$header);
       
    curl_setopt($chCURLOPT_URL$postUrl); 
       
    curl_setopt($chCURLOPT_SSL_VERIFYPEERFALSE);
       
    curl_setopt($chCURLOPT_POST);
       
    curl_setopt($chCURLOPT_POSTFIELDSclient_info($urlSetting$sSoapAction$username$password$partnerId$productId$ratePlanId$responseGroups$zipcode));
       
    curl_setopt($chCURLOPT_FOLLOWLOCATION1); // process page
    // for error check
       
    curl_setopt($chCURLOPT_HEADER0);
       
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
       
    $postResult curl_exec($ch);

       if (
    curl_errno($ch)) {
           print 
    curl_error($ch);
       }
       
    curl_close($ch);
       echo 
    $postResult
    you would not believe how easy it was but how hard it was to find that answer!!

    Now see my question about UTC format and i am done this monster script!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured