LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-23-2015, 04:48 AM   #1
wowy
Member
 
Registered: Mar 2015
Location: France
Distribution: Ubuntu 14.04
Posts: 61

Rep: Reputation: Disabled
Invalid argument in function


Trying to work with soap thanks to the Gsoap toolkit, I am trying the create a client and server.

I have generated the files necessary and now I would like call a function from the client to the server but I keep getting an "invalid argument" when writing the function. It surely is something "easy" that am I simply flying over but I can't seems to find why. Any help would be appreciated.

Code of the client :
Code:
#include "soapH.h"
#include "CentralSystemServiceSoap.nsmap"

const char *endpoint = "http://192.168.2.128:8080";
const char *localhost = "http://localhost:8080";
const char server[] = "http://192.168.2.128:8080";

int main(int argc, char **argv)
{
    struct soap soap;
    soap_init(&soap);

    ns1__BootNotificationRequest BootNotificationRequest;
    BootNotificationRequest.chargePointModel="1";
    BootNotificationRequest.chargePointVendor="2";
    ns1__BootNotificationResponse BootNotificationResponse;
//error here
    soap_call___ns1__BootNotification    (&soap,server,NULL,*BootNotificationRequest,&BootNotificationResponse);

    if (soap.error)
            std::cout << "error" << std::endl;
        else
            std::cout << "SOAP OK" << std::endl;
    soap_destroy(&soap);
    soap_end(&soap);
    soap_done(&soap);
    return SOAP_OK;
}
Here are how the function soap_call___ns1__BootNotification and the parameters type ns1__BootNotificationRequest and ns1__BootNotificationResponse are defined :

Code:
SOAP_FMAC5 int SOAP_FMAC6 soap_call___ns1__BootNotification(struct soap *soap, const char *soap_endpoint, const char *soap_action,ns1__BootNotificationRequest *ns1__bootNotificationRequest, ns1__BootNotificationResponse &ns1__bootNotificationResponse)
{   struct __ns1__BootNotification soap_tmp___ns1__BootNotification;
if (soap_endpoint == NULL)
    soap_endpoint = "http://localhost/Ocpp/CentralSystemService/";
if (soap_action == NULL)
    soap_action = "/BootNotification";
soap_begin(soap);
soap->encodingStyle = NULL;
soap_tmp___ns1__BootNotification.ns1__bootNotificationRequest = ns1__bootNotificationRequest;
soap_serializeheader(soap);
soap_serialize___ns1__BootNotification(soap, &soap_tmp___ns1__BootNotification);
if (soap_begin_count(soap))
    return soap->error;
if (soap->mode & SOAP_IO_LENGTH)
{   if (soap_envelope_begin_out(soap)
     || soap_putheader(soap)
     || soap_body_begin_out(soap)
     || soap_put___ns1__BootNotification(soap, &soap_tmp___ns1__BootNotification, "-ns1:BootNotification", NULL)
     || soap_body_end_out(soap)
     || soap_envelope_end_out(soap))
         return soap->error;
}
if (soap_end_count(soap))
    return soap->error;
if (soap_connect(soap, soap_url(soap, soap_endpoint, NULL), soap_action)
 || soap_envelope_begin_out(soap)
 || soap_putheader(soap)
 || soap_body_begin_out(soap)
 || soap_put___ns1__BootNotification(soap, &soap_tmp___ns1__BootNotification, "-ns1:BootNotification", NULL)
 || soap_body_end_out(soap)
 || soap_envelope_end_out(soap)
 || soap_end_send(soap))
    return soap_closesock(soap);
if (!&ns1__bootNotificationResponse)
    return soap_closesock(soap);
ns1__bootNotificationResponse.soap_default(soap);
if (soap_begin_recv(soap)
 || soap_envelope_begin_in(soap)
 || soap_recv_header(soap)
 || soap_body_begin_in(soap))
    return soap_closesock(soap);
ns1__bootNotificationResponse.soap_get(soap, "ns1:bootNotificationResponse", NULL);
if (soap->error)
    return soap_recv_fault(soap, 0);
if (soap_body_end_in(soap)
 || soap_envelope_end_in(soap)
 || soap_end_recv(soap))
    return soap_closesock(soap);
return soap_closesock(soap);
}
When I call this function I let the third argument NULL.

ns1__BootNotificationRequest :

Code:
class SOAP_CMAC ns1__BootNotificationRequest
{
public:
std::string chargePointVendor;  /* required element of type ns1:ChargePointVendor */
std::string chargePointModel;   /* required element of type ns1:ChargePointModel */
std::string *chargePointSerialNumber;   /* optional element of type ns1:ChargePointSerialNumber */
std::string *chargeBoxSerialNumber; /* optional element of type ns1:ChargeBoxSerialNumber */
std::string *firmwareVersion;   /* optional element of type ns1:FirmwareVersion */
std::string *iccid; /* optional element of type ns1:IccidString */
std::string *imsi;  /* optional element of type ns1:ImsiString */
std::string *meterType; /* optional element of type ns1:MeterType */
std::string *meterSerialNumber; /* optional element of type ns1:MeterSerialNumber */
struct soap *soap;  /* transient */
public:
virtual int soap_type() const { return 21; } /* = unique type id SOAP_TYPE_ns1__BootNotificationRequest */
virtual void soap_default(struct soap*);
virtual void soap_serialize(struct soap*) const;
virtual int soap_put(struct soap*, const char*, const char*) const;
virtual int soap_out(struct soap*, const char*, int, const char*) const;
virtual void *soap_get(struct soap*, const char*, const char*);
virtual void *soap_in(struct soap*, const char*, const char*);
         ns1__BootNotificationRequest() { ns1__BootNotificationRequest::soap_default(NULL); }
virtual ~ns1__BootNotificationRequest() { }
};
ns1__BootNotificationResponse :

Code:
class SOAP_CMAC ns1__BootNotificationResponse
{
public:
enum ns1__RegistrationStatus status;    /* SOAP 1.2 RPC return element (when namespace qualified) */    /* required element of type ns1:RegistrationStatus */
time_t currentTime; /* required element of type xsd:dateTime */
int heartbeatInterval;  /* required element of type xsd:int */
struct soap *soap;  /* transient */
public:
virtual int soap_type() const { return 22; } /* = unique type id SOAP_TYPE_ns1__BootNotificationResponse */
virtual void soap_default(struct soap*);
virtual void soap_serialize(struct soap*) const;
virtual int soap_put(struct soap*, const char*, const char*) const;
virtual int soap_out(struct soap*, const char*, int, const char*) const;
virtual void *soap_get(struct soap*, const char*, const char*);
virtual void *soap_in(struct soap*, const char*, const char*);
         ns1__BootNotificationResponse() { ns1__BootNotificationResponse::soap_default(NULL); }
virtual ~ns1__BootNotificationResponse() { }
};
I am betting it is something basic but I can't find it.

EDIT :
I was stupid, to solve it :
soap_call___ns1__BootNotification(&soap, server, NULL,&BootNotificationRequest, BootNotificationResponse);

Last edited by wowy; 07-23-2015 at 04:50 AM. Reason: solved
 
Old 07-27-2015, 09:23 AM   #2
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
If the last line of your edit is the solution, good for you, but you should at least tag this thread as solved (click on "thread tools"). Even nicer would be if you copied the solution (e.g. in red) below the offending wrong line in another short example of the source code and explained what was why wrong (would help beginners). Thanks, congrats & bye.
 
  


Reply

Tags
argument, c++, function, soap, web service



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] case function for no-argument - default function for script? Batistuta_g_2000 Linux - Newbie 3 03-13-2013 10:00 AM
invalid argument azza Programming 1 07-01-2009 09:45 PM
invalid argument azza Programming 1 06-29-2009 08:25 AM
message sending failed : Error[22 ] invalid argument .....but each and every argument rakeshranjanjha Linux - Software 2 01-07-2008 11:22 PM
alsa mixer sayin "function snd_mixer_load failed:invalid argument" callmeleroi Fedora 0 03-11-2007 09:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration