Press enter to see results or esc to cancel.

Send SOAP Request with custom variables and read XML response from PHP page

In this video I have shown how we can send XML request with custom variables set from a HTML form.
The XML Response received is parsed and shown in same page.

For testing this, I have found the website which will give response for XML request we send.

1. The Sample XML Request we are going to send is shown below

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
  <GetHolidaysForYear xmlns="">

2. The response for the above request is shown below,

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd="">
 <GetHolidaysForYearResponse xmlns="">
    <Descriptor>New Year's Day</Descriptor>
    <Descriptor>New Year's Day</Descriptor>

3.The form.php page with simple HTML form to create the XML to submit data.

<title>Send SOAP XML Reqeuest using Custom varaibles</title>
<script src=""></script>
  function submit_soap(){
    var country=$("#country_name").val();
    var year=$("#year").val();
    <h3>Send SOAP XML Reqeuest using Custom varaibles</h3>
     <form id="myForm" method="post">
      Country Name : <input name="country_name" id="country_name" type="text" /><br />
      Year: <input name="year" id="year" type="text" /><br />
      <input type="button" value="Submit" onclick="submit_soap()" />
    <div id="xml_response"></div>

4. The XML request is send from callme.php. We take the value from the form and submit the value to the callme.php page using jquery.

 $soapclient = new SoapClient('');
 $response =$soapclient->GetHolidaysForYear($param);
 echo '<br><br><br>';
 $array = json_decode(json_encode($response), true);

  function dispaly_array_recursive($array_rec){
       foreach($array_rec as $value){
         echo $value.'<br>';
}catch(Exception $e){
    echo $e->getMessage();

4. The form and result is shown as below.



Comments are disabled for this post