soap - Client looks like we got no XML document in soapclient php -


i have problem in using soapclient in php. considering fist try in authenticating user credentials might have basic mistakes in code well. have simple html tags takes user credentials(on client side) , sends them processing page (works in backend) , sends soap message server page using __soapcall. here code. please suggestions

client.php

<html> <body>     <form method='post' action='middle_client.php'>         <lable>user name</lable><input type='text' name= 'user' id='user'>         <br>         <lable>password</lable><input type='password' name= 'pass'>         <br>         <lable>insurance name</lable><input type='text' name= 'insurance'>         <br>         <input type='submit' name= 'submit'>  </form> <body> </html> 

middle_client.php

<?php  use \soapclient;  if(isset($_post['submit'])){                     $name= $_post['user'];                     $password= $_post['pass'];                     $insurance= $_post['insurance'];                       $con=mysql_connect("localhost","root","");                             // check connection                              if (!$con) {                                die('not connected : ' . mysql_error());                                 }                              $db_selected = mysql_select_db($insurance, $con);                              if (!$db_selected) {                                 die('invalid query: ' . mysql_error());                             }                              if ($db_selected=='insurance'){                                 //header('location:server.php');                                 }  } class client{ function __construct(){              $parameters = array('location' => 'http://localhost/xxx/server.php',                                      "uri" => 'urn://localhost/xxx/',                                     'trace' => 1,                                 );               $this->instance = new soapclient(null,$parameters);              $auth_parameter = new stdclass();              $auth_parameter->name = "abc";                $auth_parameter->password = "root";              $header_param = new soapvar($auth_parameter, soap_enc_object);               $header = new soapheader('xxx', 'authenticate', $header_param, false);              $this->instance->__setsoapheaders(array($header));  }   public function getname($array){             return $this->instance->__soapcall('testing', $array); } }   $client = new client(); $array = array ('p_name'=> 'foo'); echo $result = $client->getname($array); var_dump($client); ?> 

and server.php

<?php class server{ private $con; public function authenticate($header_param){                      if ($header_param->name == 'abc' && $header_param->password == 'root' ){                         return true;                      }                      else throw new soapfault("wrong name/password", 401);                                    }  public function __construct(){      $this->con = (is_null($this->con)) ? self::connect() : $this->con;                     }  static function connect(){                     $con=mysql_connect("localhost","root","insurance");                             // check connection                              if (mysqli_connect_errno()){                               echo "failed connect mysql: " . mysqli_connect_error();                             }                             $db = mysql_select_db("user", $con);                         return $con; }     public function testing($array){     $usernme = $array['p_name'];                              $sql = "select * user p_name=".$usernme;                             $qry= mysql_query($sql,$this->con);                             $result = mysql_fetch_array($qry);                              if (!$result) {                                 die('invalid query: ' . mysql_error());                             }                              /return $returned_name= $result["p_name"];  } }   $parameter = array("uri" => 'localhost/xxx/server.php');  $server = new soapserver(null, $parameter);  $server-> setclass('server');  $server-> handle(); 


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -