Complex of data is not returning in php web services (nusoap)

Help
manoj
2013-07-30
2013-07-30
  • manoj
    manoj
    2013-07-30

    Hi all,

    here I created two function
    1) first function return a single line of result
    2) second function return a complex of result like array of result.

    first function is working fine, when I invoke second function it's not returning result

    could you tell me where I went wrong?

    my php code is

    //index.php

    require_once("nuSOAP/lib/nusoap.php");

    $namespace = "http://localhost/nusoaphelloworld/index.php";
    // create a new soap server
    $server = new soap_server();
    // configure our WSDL
    $server->configureWSDL("HelloExample");
    // set our namespace
    $server->wsdl->schemaTargetNamespace = $namespace;

    //Register a method that has parameters and return types
    $server->register(
    // method name:
    'HelloWorld',
    // parameter list:
    array('name'=>'xsd:string'),
    // return value(s):
    array('return'=>'xsd:string'),
    // namespace:
    $namespace,
    // soapaction: (use default)
    false,
    // style: rpc or document
    'rpc',
    // use: encoded or literal
    'encoded',
    // description: documentation for the method
    'Simple Hello World Method');

    //Create a complex type
    $server->wsdl->addComplexType('MyComplexType','complexType','struct','all','',
    array( 'contact' => array('name' => 'contact','type' => 'xsd:string'),
    'email' => array('name' => 'email','type' => 'xsd:string')));

    //Register our method using the complex type
    $server->register(
    // method name:
    'HelloComplexWorld',
    // parameter list:
    array(),
    // return value(s):
    array('return'=>'tns:MyComplexType'),
    // namespace:
    $namespace,
    // soapaction: (use default)
    false,
    // style: rpc or document
    'rpc',
    // use: encoded or literal
    'encoded',
    // description: documentation for the method
    'Complex Hello World Method');

    //Our Simple method
    function HelloWorld($name)
    {
    return "Hello " . $name;
    }

    //Our complex method
    function HelloComplexWorld()
    {
    //return $mycomplextype;
    $result = array();
    $result[] = array( 'contact' => 'Manoj', 'email' => 'manoj@gmail.com');
    $result[] = array( 'contact' => 'munna', 'email' => 'munna@gmail.com');

    return $result;
    

    }

    // Get our posted data if the service is being consumed
    // otherwise leave this data blank.
    $POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';

    // pass our posted data (or nothing) to the soap service
    $server->service($POST_DATA);
    exit();

    ?>

    //client.php

    /*
    * @author
    * @copyright 2013
    /

    require 'nuSOAP/lib/nusoap.php';

    $response = new nusoap_client('http://localhost:8080/myfiles/nusoaphelloworld/index.php?wsdl');

    $result = $response->call('HelloWorld',array('name'=>'Manoj'));

    $result1 = $response->call('HelloComplexWorld',array());

    print_r($result);

    echo '

    ';

    print_r($result1);

    //echo '

    ';

    //var_dump($result1);

    ?>

    my result is:

    First function result is : Hello Manoj

    Second function reslut is:

    Array
    (
    [contact] =>
    [email] =>
    )

    here not displaying result ?

    anyone can tell me where I went wrong?

    thanks in advance..........