title: The basics of SOAP used with PHP
body: <p>I know that it's not the main idea of this site to answer such kind of questions but in couple of days I'll have the chance to apply for a junior (or maybe more correctly a probationer) position as a PHP programmer and that's why I decided to post here, hoping it will turn out good.
    The company is some kind of big compared to others here, so it's well known what is the exam for people wanting to get in this position - it's either - writing a pagination script or some sort of SOAP service.I have no problem with the pagination, but since now I have never payed too much attention to SOAP and now I need to learn tha basics ot SOAP service when used with PHP.Giving the postion I'm applying for, noone expect to show something brilliant but I still I need basic understanding of SOAP client and server sevices, maybe I won't even bother for now about WSDL since I don't think I have enough time for everything.
    So I have a sample code that is most likely what I'll need to write and explain If I'm to write SOAP service :</p>
  
  <p>Client side -</p>
  
  <pre><code>&lt;?php
  
  if (isset($_REQUEST["cname"]) &amp;&amp; isset($_REQUEST["cpass"])) 
  {
    $cname = $_REQUEST["cname"];
    $md5pass = md5( $_REQUEST["cpass"]);
  
    $client = new SoapClient(null, array(
        'location' =&gt; "http://localhost/test/BuildInSoapWithWSDL/server.php",
        'uri'      =&gt; "urn://localhost/test/BuildInSoapWithWSDL/",
        'trace'    =&gt; 1 ));
    try 
    {
  
          if ( $client-&gt;saveUserNameAndPass($cname, $md5pass)) 
             {echo "Data updated!";} 
      else 
        {echo "Error updating data!";}
  
          print "&lt;pre&gt;\n";
      print "Request :\n".htmlspecialchars($client-&gt;__getLastRequest()) ."\n";
      print "Response:\n".htmlspecialchars($client-&gt;__getLastResponse())."\n";
      print "&lt;/pre&gt;";
    }
    catch (Exception $e) 
    {
        echo 'Exception: ',  $e-&gt;getMessage(), "\n";
    }
  }
  else
  { 
    echo "Error!"; 
  }
  
  ?&gt;
  </code></pre>
  
  <p>server side -</p>
  
  <pre><code>&lt;?php
  
  $server = new SoapServer(null, array('uri' =&gt; 'urn://localhost/test/BuildInSoapWithoutWSDL/'));
  $server-&gt;addFunction("saveUserNameAndPass");
  $server-&gt;handle();
  
  function database_connect($host, $account, $password, $dbname)
  {
    $connect = mysql_connect($host, $account, $password);
    $connect = mysql_select_db($dbname, $connect);
    return $connect;
  }
  
  function saveUserNameAndPass($userName,$passWord) 
  {
     try 
     {
        if (database_connect("localhost", "saveuser", "123456", "savetask") == 1)
        {
          $userName = mysql_real_escape_string($userName);
          $sql = "INSERT INTO accounts (name,passmd5) VALUES ('".$userName."','".$passWord."')";
          $result = mysql_query($sql);
          mysql_close();
          if ($result) 
            { return true;}
          else
            { return false;}
        }
        else
        { 
            return false; 
        }
     }
     catch (Exception $e) 
     {
       return false;
     }
  }
  ?&gt;
  </code></pre>
  
  <p>Even I have the code I still have poor knowledge of what do what.So I need some explanation ot the basics when writing SOAP service and if it's not acceptable this topci to be discussed here I would appreciate any kind of source where these thing are explained from the point of beginner.</p>
  
  <p>Thanks</p>