Reputation: 13
I'm using gsoap to communicate with the following webservice: http://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl
I've run the soapcpp2 to generate the header files, here's my soapClient.c: http://pastebin.com/Bjev3dP7
getquote:
struct _ns1__GetQuote
{
/// Element "StockSymbol" of XSD type xs:string.
char* StockSymbol 0; ///< Optional element.
/// Element "LicenseKey" of XSD type xs:string.
char* LicenseKey 0; ///< Optional element.
};
struct _ns1__GetQuoteResponse
{
/// Element "GetQuoteResult" of XSD type "http://ws.cdyne.com/":QuoteData.
struct ns1__QuoteData* GetQuoteResult 1; ///< Required element.
};
here's my code so far:
#include "soapH.h"
#include "DelayedStockQuoteSoap.nsmap"
#include "soapClient.c"
struct _ns1__GetQuote *ns1__GetQuote;
struct _ns1__GetQuoteResponse *response;
main() {
struct soap *soap ;
ns1__GetQuote->StockSymbol = "goog";
ns1__GetQuote->LicenseKey = "0";
if (soap_call___ns1__GetQuote(soap, NULL, NULL, ns1__GetQuote, &response) == SOAP_OK)
printf("yay\n");
}
I get a segfault as soon as I run this code, any hints?
Upvotes: 0
Views: 135
Reputation: 11962
In your code there are many errors, nothing is allocated.
First you need to allocate the struct soap
using:
struct soap *soap = soap_new();
Next input and output arguments of GetQuote
method need to be allocated, this could be easily done storing in the stack :
struct _ns1__GetQuote ns1__GetQuote;
struct _ns1__GetQuoteResponse response;
Putting all together could give something like:
#include "soapH.h"
#include "DelayedStockQuoteSoap.nsmap"
#include "soapClient.c"
main() {
struct soap *soap = soap_new();
struct _ns1__GetQuote ns1__GetQuote;
struct _ns1__GetQuoteResponse response;
ns1__GetQuote.StockSymbol = "goog";
ns1__GetQuote.LicenseKey = "0";
if (soap_call___ns1__GetQuote(soap, NULL, NULL, &ns1__GetQuote, &response) == SOAP_OK)
printf("yay\n");
}
Upvotes: 1