Search code examples
c++soapgsoap

gSoap specify Input parameter With class Compound Data Type


i'm trying to create a method that has a class as one of his parameters. when I send from the client to the server i found that the object send is always empty this is my .h file that i used to generate the server and the client

class FamilleProduit
{
private:
    int Id;
    std::string Libelle;
public:
    FamilleProduit();
    ~FamilleProduit();
    int getId();
    void setId(int value);
    std::string getLibelle();
    void setLibelle(std::string value);
};


int ns__ajouterByType ( FamilleProduit familleproduit, bool* result);
int ns__ajouterByLibelle ( std::string libelle, bool* result);

and this is the client

.......
struct soap m;
FamilleProduit f;
f.setLibelle("byTypeLocal");
soap_init(&m);
soap_call_ns__ajouterByType(&m,server,"",f,&res);
.........

this is the server part

int ns__ajouterByType(struct soap* soap, FamilleProduit f, bool *result){
    cout<<"Ajout FamilleProduit "<<f.getLibelle()<<endl;

    return SOAP_OK;
}

I found that always the object FamilleProduit is empty

For information i'm using the same code to send a string and i have no problem.

plz help and thank you all


Solution

  • I found the problem, it was in the declaration of class FamilleProduit I must put the attribute public. I don't know why! but it works. The new .h file

    // Content of file "Test.h": 
    //gsoap ns service name: Test 
    //gsoap ns service protocol: SOAP 
    //gsoap ns service style: rpc 
    //gsoap ns service encoding: encoded 
    //gsoap ns schema namespace: urn:MutexColisage
    
    class ns1__FamilleProduit
    {
        int Id;
        std::string Libelle;
        ns1__FamilleProduit();
        ~ns1__FamilleProduit();
        int getId();
        void setId(int value);
        std::string getLibelle();
        void setLibelle(std::string value);
    };
    
    
    int ns__ajouterByType ( ns1__FamilleProduit *familleproduit, bool* result);
    int ns__ajouterByLibelle ( std::string libelle, bool* result);