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 6379721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:10:28+00:00 2026-05-25T02:10:28+00:00

Since the SOAP manual on php.net is not very noob friendly and I could

  • 0

Since the SOAP manual on php.net is not very noob friendly and I could not find any good examples I will post my question here.

How can I create PHP SOAP request to look like this?

POST /MySERVER/myWSDLservice.asmx HTTP/1.1
Host: connection.mywebsite.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://connection.mywebsite.com/MySERVER/GetCarType"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
  <GetCarType xmlns="http://connection.mywebsite.com/MySERVER/">
    <IDNumber>string</IDNumber>
  </GetCarType>
 </soap:Body>
</soap:Envelope>

Please note:

  • there is user/pass auth
  • SSL connection

Any suggestion / links / example much appreciated.

  • 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-25T02:10:29+00:00Added an answer on May 25, 2026 at 2:10 am

    Tested and working!

    • with https, user & password

       <?php 
       //Data, connection, auth
       $dataFromTheForm = $_POST['fieldName']; // request data from the form
       $soapUrl = "https://connecting.website.com/soap.asmx?op=DoSomething"; // asmx URL of WSDL
       $soapUser = "username";  //  username
       $soapPassword = "password"; // password
      
       // xml post structure
      
       $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
                           <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                             <soap:Body>
                               <GetItemPrice xmlns="http://connecting.website.com/WSDL_Service"> // xmlns value to be set to your WSDL URL
                                 <PRICE>'.$dataFromTheForm.'</PRICE> 
                               </GetItemPrice >
                             </soap:Body>
                           </soap:Envelope>';   // data from the form, e.g. some ID number
      
          $headers = array(
                       "Content-type: text/xml;charset=\"utf-8\"",
                       "Accept: text/xml",
                       "Cache-Control: no-cache",
                       "Pragma: no-cache",
                       "SOAPAction: http://connecting.website.com/WSDL_Service/GetPrice", 
                       "Content-length: ".strlen($xml_post_string),
                   ); //SOAPAction: your op URL
      
           $url = $soapUrl;
      
           // PHP cURL  for https connection with auth
           $ch = curl_init();
           curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
           curl_setopt($ch, CURLOPT_URL, $url);
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
           curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
           curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
           curl_setopt($ch, CURLOPT_TIMEOUT, 10);
           curl_setopt($ch, CURLOPT_POST, true);
           curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
           curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      
           // converting
           $response = curl_exec($ch); 
           curl_close($ch);
      
           // converting
           $response1 = str_replace("<soap:Body>","",$response);
           $response2 = str_replace("</soap:Body>","",$response1);
      
           // convertingc to XML
           $parser = simplexml_load_string($response2);
           // user $parser to get your data out of XML response and to display it. 
       ?>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since two days I am trying to consume a WCF (.NET) Soap Service and
Since I did a change : Rewrite an asp.net mvc ajax actionlink as a
Since Knockout's individual templates are kept in script tags, I thought that I could
Since Graduating from a very small school in 2006 with a badly shaped &
I'm implementing a SOAP client using Apache Axis 2. Since the SOAP client must
Since this question tells me that SoapHttpClientProtocol is not thread safe. And, my real
Is there any way to make non-blocking SOAP requests within EventMachine? I'm creating a
It's been more than two years since someone asked Which SOAP XML object serialization
I have been digging since last three days to find out the appropriate way
I haven't really looked into the new .NET stuff since 2.0, but I'm wondering

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.