www.pudn.com > TestGSOAP_SSL.zip > TestGSOAP.cpp


// TestGSOAP.cpp : Defines the entry point for the console application. 
// 
 
#include "stdafx.h" 
#include "soapH.h"      /* include generated proxy and SOAP support */ 
 
int main(int argc, char* argv[]) 
{ 
	_ns1__getQuote getQuote; 
	_ns1__getQuoteResponse getQuoteResponse; 
	struct soap soap; 
	if (argc > 1) 
		getQuote.symbol = argv[1]; 
	else 
	{  
		fprintf(stderr, "Usage: quote \n"); 
		return -1; 
	} 
	 
	/* Init OpenSSL */ 
	soap_ssl_init(); 
 
	soap_init(&soap); 
 
	if (soap_ssl_client_context(&soap, 
		SOAP_SSL_NO_AUTHENTICATION, 	/* use SOAP_SSL_DEFAULT in production code */ 
		NULL, 		/* keyfile: required only when client must authenticate to server (see SSL docs on how to obtain this file) */ 
		NULL, 		/* password to read the keyfile */ 
		NULL,		/* optional cacert file to store trusted certificates */ 
		NULL,		/* optional capath to directory with trusted certificates */ 
		NULL		/* if randfile!=NULL: use a file with random data to seed randomness */  
		)) 
	{  
		soap_print_fault(&soap, stderr); 
		exit(1); 
	} 
 
	if (soap_call___ns1__getQuote(&soap, "https://localhost:9443/WebProject/services/StockQuoteService", NULL, &getQuote, &getQuoteResponse) == 0) 
		printf("\nCompany - %s    Quote - %f\n", getQuote.symbol, getQuoteResponse.getQuoteReturn); 
	else 
		soap_print_fault(&soap, stderr); 
	return 0; 
} 
 
/* The namespace mapping table is required and associates namespace prefixes with namespace names: */ 
struct Namespace namespaces[] = 
{ 
  {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"},    /* MUST be first */ 
  {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"},    /* MUST be second */ 
  {"xsi", "http://www.w3.org/1999/XMLSchema-instance"},         /* MUST be third */ 
  {"xsd", "http://www.w3.org/1999/XMLSchema"}, 
  {"ns1", "http://stockquote"},       /* Method namespace URI */ 
  {NULL, NULL} 
};