strange response of a webservice

  • kermit

    kermit - 2011-01-21


    I'm new in nusoap.
    I'm trying to build a simple webservice: suppose to have an order of one or more items, giving the order id to webservice it answer with a list of items.

    Here is my code:

    //includiamo la libreria NuSOAP
    //definiamo il nostro namespace privato come abbiamo fatto anche nel capitolo WSDL
    define("NAMESPACE", "http://localhost");
    //creiamo un istanza del server fornito da nusoap
    $server = new soap_server;
    //disattiviamo il debug
    //cominciamo a configurare un documento WSDL (che sarà elaborato da NuSOAP) per il nostro Web service
    $server->configureWSDL('wsprova', NAMESPACE); // <-- diamo un nome al webservice ed impostiamo il nostro namespace
    $server->wsdl->schemaTargetNamespace = NAMESPACE; // <-- impostiamo il nostro namespace anche come target dello schema WSDL (come abbiamo fatto nell'esempio WSDL)
            'Name' => array('name'=>'name','type'=>'xsd:string'),
            'Code' => array('name'=>'product_number','type'=>'xsd:string'),
            'Price' => array('name'=>'price','type'=>'xsd:decimal'),
            'Ammount' => array('name'=>'quantity','type'=>'xsd:int'),
        'xx' => array('name'=>'xx','type'=>'xsd:int')                                   [b]//<===== HERE IS THE PROBLEM !!!!!!!!![/b]
    function GetProductsByCode($product_code){
        $return =array();
            'Name' =>'a',
            'Code' => 'b',
            'Price' => '1.1',
            'Ammount' => '1',
        'xx' => '1'
            'Name' =>'c',
            'Code' => 'd',
            'Price' => '2.2',
            'Ammount' => '2',
            'xx' => '1'
        return $return;
    exit(); //non scrivere nulla sotto questa linea

    I'm using soapui to test this service and in this case it give me a strance sequence of character (not an xml string).

    If I comment this line:

    'xx' => array('name'=>'xx','type'=>'xsd:int')                                   [b]//<===== HERE IS THE PROBLEM !!!!!!!!![/b]

    it works find !!!!

    Please can anyone help me?


  • Scott Nichol

    Scott Nichol - 2011-01-21

    Two things came up when I tried to run the above code.

    1. define("NAMESPACE", "http://localhost")

    PHP was OK with this line, but not with subsequent lines that used NAMESPACE.  I changed NAMESPACE to MYNAMESPACE and the errors went away.

    2. $server->register(

    Notice that NAMESPACE is incorrectly referenced as a variable $NAMESPACE.  I changed this to MYNAMESPACE.

    Once I made these two changes, a simple client script was able to correctly access the service.

  • kermit

    kermit - 2011-01-25

    Thank you for the answer,  I made the suggested correction and now it works…but in my opinion web service output grater than 1024 byte are automatically compressed, isn't it?

  • kermit

    kermit - 2011-01-25

    OK I have solved my problem.
    It was about compressed response and SoapUI paramethers.

    If you got the same problem, look at soapui preference and remouve the flag on "Response compression".

    snichol Thank you for your support


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks