00001 /*** Copyright (c), The Regents of the University of California *** 00002 *** For more information please refer to files in the COPYRIGHT directory ***/ 00003 00004 /** 00005 * @file stockQuoteMS.c 00006 * 00007 * @brief Access to stock quotation web services 00008 * 00009 * This microservice handles comminication with http://www.webserviceX.NET 00010 * and provides stock quotation - delayed by the web server. 00011 * 00012 * 00013 * @author Arcot Rajasekar / University of California, San Diego 00014 */ 00015 00016 #include "rsApiHandler.h" 00017 #include "stockQuoteMS.h" 00018 #include "stockQuoteH.h" 00019 #include "stockQuote.nsmap" 00020 00021 00022 /** 00023 * \fn msiGetQuote(msParam_t* inSymbolParam, msParam_t* outQuoteParam, ruleExecInfo_t* rei ) 00024 * 00025 * \brief Returns stock quotation (delayed by web service) using web service provided by http://www.webserviceX.NET 00026 * 00027 * \module webservices 00028 * 00029 * \since pre-2.1 00030 * 00031 * \author Arcot Rajasekar 00032 * \date 2008-05 00033 * 00034 * \usage See clients/icommands/test/rules3.0/ 00035 * 00036 * \param[in] inSymbolParam - a msParam of type STR_MS_T which is a stock symbol. 00037 * \param[out] outQuoteParam - a msParam of type STR_MS_T which is a stock quotation as a float printed onto string. 00038 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00039 * handled by the rule engine. The user does not include rei as a 00040 * parameter in the rule invocation. 00041 * 00042 * \DolVarDependence none 00043 * \DolVarModified none 00044 * \iCatAttrDependence none 00045 * \iCatAttrModified none 00046 * \sideeffect none 00047 * 00048 * \return integer 00049 * \retval 0 on success 00050 * \pre none 00051 * \post none 00052 * \sa none 00053 **/ 00054 int 00055 msiGetQuote(msParam_t* inSymbolParam, msParam_t* outQuoteParam, ruleExecInfo_t* rei ) 00056 { 00057 00058 struct soap *soap = soap_new(); 00059 struct _ns1__GetQuote sym; 00060 struct _ns1__GetQuoteResponse quote; 00061 char response[10000]; 00062 00063 RE_TEST_MACRO( " Calling msiGetQuote" ); 00064 00065 sym.symbol = (char *) inSymbolParam->inOutStruct; 00066 00067 soap_init(soap); 00068 soap_set_namespaces(soap, stockQuote_namespaces); 00069 /* if (soap_call___ns3__GetQuote(soap, NULL, NULL, &sym, "e) == SOAP_OK) { */ 00070 if (soap_call___ns2__GetQuote(soap, NULL, NULL, &sym, "e) == SOAP_OK) { 00071 fillMsParam( outQuoteParam, NULL, 00072 STR_MS_T, quote.GetQuoteResult, NULL ); 00073 free (quote.GetQuoteResult); 00074 return(0); 00075 } 00076 else { 00077 sprintf(response,"Error in execution of stockQuote::%s\n",soap->buf); 00078 fillMsParam( outQuoteParam, NULL, 00079 STR_MS_T, response, NULL ); 00080 return(0); 00081 } 00082 } 00083