Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6529925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:41:41+00:00 2026-05-25T09:41:41+00:00

I saw this post on consuming a web service using CURL: Consume WebService with

  • 0

I saw this post on consuming a web service using CURL: Consume WebService with php

and I was trying to follow it, but haven’t had luck. I uploaded a photo of the web service I’m trying to access. How would I formulate my request given the example below, assuming the URL was:

https://site.com/Spark/SparkService.asmx?op=InsertConsumer

enter image description here

I attempted this, but it just returns a blank page:

 $url = 'https://xxx.com/Spark/SparkService.asmx?op=InsertConsumer?NameFirst=Joe&NameLast=Schmoe&PostalCode=55555&EmailAddress=joe@schmoe.com&SurveyQuestionId=76&SurveyQuestionResponseId=1139';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    curl_close($ch);

    $xmlobj = simplexml_load_string($result);
    print_r($xmlobj);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:41:42+00:00Added an answer on May 25, 2026 at 9:41 am

    Really, you should probably look at the SOAP extension. If it is not available or for some reason you must use cURL, here is a basic framework:

    <?php
    
      // The URL to POST to
      $url = "http://www.mysoapservice.com/";
    
      // The value for the SOAPAction: header
      $action = "My.Soap.Action";
    
      // Get the SOAP data into a string, I am using HEREDOC syntax
      // but how you do this is irrelevant, the point is just get the
      // body of the request into a string
      $mySOAP = <<<EOD
    <?xml version="1.0" encoding="utf-8" ?>
    <soap:Envelope>
      <!-- SOAP goes here, irrelevant so wont bother writing it out -->
    </soap:Envelope>
    EOD;
    
      // The HTTP headers for the request (based on image above)
      $headers = array(
        'Content-Type: text/xml; charset=utf-8',
        'Content-Length: '.strlen($mySOAP),
        'SOAPAction: '.$action
      );
    
      // Build the cURL session
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_POST, TRUE);
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $mySOAP);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    
      // Send the request and check the response
      if (($result = curl_exec($ch)) === FALSE) {
        die('cURL error: '.curl_error($ch)."<br />\n");
      } else {
        echo "Success!<br />\n";
      }
      curl_close($ch);
    
      // Handle the response from a successful request
      $xmlobj = simplexml_load_string($result);
      var_dump($xmlobj);
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw this post but didn't understand if this was the same issue. My
I saw this post on SO already but it still begs the question, at
I saw this post but mine is slightly different: Rails ActionMailer with multiple SMTP
I saw this post Ruby on Rails - Awesome nested set plugin but I
I saw this post on SO: UISearchBar solid color But no answer was provided.
I saw this post about using the new holographic themes on Honeycomb: Change theme
I saw this question asked about C# I would like an answer for PHP.
I recently saw this code on another post ( jQuery Set Cursor Position in
Saw this post at CodeProject for FCKEditor. Can someone explain what about the new
I saw this post: Typos… Just use option strict and explicit please.. during one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.