nuSoap server - complex types in request?

Help
2010-02-26
2016-02-28
  • jared chmielecki

    I was wondering if anyone has successfully used nuSOAP server to create a method that takes in a complex type and returns a simple result set... IE pass in the equivilant of a SQL result set, and then get a response such as a success code and message.
    It is pretty cut and paste from the available examples to create the opposite, passing in a list of parameters and then getting a complex type out, but swapping the complexType to the in area does not seem to work for me.
    some example code that runs fine, but does nothing with the web service explorer tool built into Eclipse:
    /**Begin Set Recording definitions ****/
    // data type to hold the recording definition
    $server->wsdl->addComplexType(
    'recordingDefinition',
    'element',
    'struct',
    'all',
    '',
    array (
    'aaa' => array (
    'name' => 'aaa',
    'type' => 'xsd:string'
    ),
    'bbb' => array (
    'name' => 'bbb',
    'type' => 'xsd:string'
    ),
    'ccc' => array (
    'name' => 'ccc',
    'type' => 'xsd:string'
    ),

        )
    );
    //recordingDefinitionRequest request type, an array of recordingDefinition 
    $server->wsdl->addComplexType(
        'recordingDefinitionRequest',
        'complexType',
        'array',
        '',
        'SOAP-ENC:Array',
        array(),
        array(
            array(
                'ref' => 'SOAP-ENC:arrayType',      
                'wsdl:arrayType' => 'tns:recordingDefinition[]')
            ),
        'tns:recordingDefinition'
    );
    // register function for webservice setRecordingDefinitions
    $server->register(
        'setRecordingDefinitions',
        array ( 'recordingDefinitionRequest' => 'tns:recordingDefinitionRequest'),  
        array ( 'code' => 'xsd:string',  'message' => 'xsd:string' ),
        'uri:iptvsoap',
        'uri:iptvsoap/setRecordingDefinitions',
        'document',
        'literal',
        //'encoded',
        'Accepts a list of recording for an active user in the system'
    );
    /***************End Set Recording definitions *****************/
    
     
  • jared chmielecki

    okay, I am embarassed, I poked at this on and off all day and then the final attempt of the day I found a great link and tried this:

    // data type to hold the recording definition
    $server->wsdl->addComplexType(
        'recordingDefinition',
        'complexType',
        'struct',
        'all',
        '',
        array (
            'aaa' => array (            'name' => 'aaa',            'type' => 'xsd:string'      ),
            'bbb' => array (            'name' => 'bbb',            'type' => 'xsd:string'      ),
            'ccc' => array (            'name' => 'ccc',            'type' => 'xsd:string'      )       
        )
    );
    //recordingDefinitionRequest request type, an array of recordingDefinition 
    $server->wsdl->addComplexType(
        'arrayOfRecordingDefinition',
        'complexType',
        'array',
        'all',
        '',     
        array(
            'desc' => array(    'name' => 'desc',   
                                'type' => 'tns:recordingDefinition',
                                'minOccurs' => '0', 
                                'maxOccurs' => 'unbounded')
        )
    
    );
    // register function for webservice setRecordingDefinitions
    $server->register(
        'setRecordingDefinitions',
        array ( 'recordingDefinitionRequest' => 'tns:arrayOfRecordingDefinition'),  
        array ( 'code' => 'xsd:string',  'message' => 'xsd:string' ),
        'uri:iptvsoap',
        'uri:iptvsoap/setRecordingDefinitions',
        'document',
        'literal',
        //'encoded',
        'Accepts a list of recording for an active user in the system'
    );
    /***************End Set Recording definitions *****************/
    

    based on the insight from:
    http://kkalev.wordpress.com/2009/02/20/nusoap-documentation-repository/

    which is basically exacltly what I was looking for.. to input an array of structures, I just needed to code it differently than the method that worked for outputs. (read the link for better explanation)

     
  • Nhuchhe Ram Mushyakhwo

    Hello,
    After defining web service(with nusoap v1.63) parameters as defined above:

    I get empty xml request i.e, the request parameters are not listed in request xml
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:setRecordingDefinitions">
    <SOAP-ENV:Body>
    <setRecordingDefinitions xmlns="urn:setRecordingDefinitions"></setRecordingDefinitions>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    what I did in client is as follows:

    $wsdl = WSDLURL;
    $client = new nusoap_client($wsdl, true);
    $params=array("aaa"=>"aaa", "bbb"=>"bbb","ccc"=>"ccc");
    $result = $client->call( "GetBankDetails", array("parameters"=>$params), $ns);

        echo '<h2>Result</h2><pre>';
        print_r($result);
        echo '</pre>';
    

    echo '

    Request

    ' . htmlspecialchars($client->request, ENT_QUOTES) . '
    ';
    echo '

    Response

    ' . htmlspecialchars($client->response, ENT_QUOTES) . '
    ';
    echo '

    Debug

    ' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '
    ';

    The expected Request xml is as follows:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:setRecordingDefinitions"> <SOAP-ENV:Body> <setRecordingDefinitions xmlns="urn:setRecordingDefinitions"> <aaa>aaa</aaa> <bbb>bbb</bbb> <ccc>ccc</ccc> </setRecordingDefinitions> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

    Please help:
    thanks in advance.

     

Log in to post a comment.