1

I am writing a simple web service methods using nusoap library in php. I already create a complextype (struct) in server side but I want to instantiate that struct in a method so I can return it. I saw an example in here but using keyword "new" doesn't work. It doesn't see ComplexType. So how can I create new ComplexLogin struct in my LoginTest function?

  //ComplexLoginType
 $server->wsdl->addComplexType('ComplexLogin','complexType','struct','all','',
array( 
    'EnterpriseId' => array('name' => 'EnterpriseId','type' => 'xsd:int'),
    'FirstName' => array('name' => 'FirstName','type' => 'xsd:string'),
    'Password' => array('name' => 'Password','type' => 'xsd:string'))
    );


$server->register(
// method name:
'LoginTest',
// parameter list:
array('name'=>'tns:ComplexLogin'),
// return value(s):
array('return'=>'tns:ComplexLogin'),
// namespace:
$namespace,
// soapaction: (use default)
false,
// style: rpc or document
'rpc',
// use: encoded or literal
'encoded',
// description: documentation for the method
'Login Method'
 );
Community
  • 1
  • 1
Ardahan Kisbet
  • 641
  • 1
  • 13
  • 33

1 Answers1

0

I cannot instantiate ComplexType directly but if I use array instead, it works correctly. However I wonder if there is another way to return ComplexType without using arrays?

My complete working function in server side;

function LoginTest($mycomplexlogin)
{
    $conn=openConnection();
    // Check connection
    if ($conn->connect_error)
    {
        //return("Connection failed: " . $conn->connect_error);
        return NULL;
    } 
    $EnterpriseId=mysqli_real_escape_string($conn,$mycomplexlogin["EnterpriseId"]);
    $FirstName=mysqli_real_escape_string($conn,$mycomplexlogin["FirstName"]);
    $Password=mysqli_real_escape_string($conn,$mycomplexlogin["Password"]);

    $result=array('EnterpriseId'=>$EnterpriseId, 'FirstName'=>$FirstName,'Password'=>$Password);
    return $result;
}
Ardahan Kisbet
  • 641
  • 1
  • 13
  • 33