00001 /** 00002 * @file ip2locationMS.c 00003 * 00004 * @brief Gives the location information given an ipaddress 00005 * 00006 * This webservice can be used to find location information including lat/long for 00007 * a given ipaddress. The web service is provided by http://ws.fraudlabs.com/ 00008 * 00009 * 00010 * @author Arcot Rajasekar / University of California, San Diego 00011 */ 00012 00013 /*** Copyright (c), The Regents of the University of California *** 00014 *** For more information please refer to files in the COPYRIGHT directory ***/ 00015 00016 #include "rsApiHandler.h" 00017 #include "ip2locationMS.h" 00018 #include "ip2locationH.h" 00019 #include "ip2location.nsmap" 00020 00021 00022 /** 00023 * \fn msiIp2location(msParam_t* inIpParam, msParam_t* inLocParam, msParam_t* outLocParam, ruleExecInfo_t* rei ) 00024 * 00025 * \brief Web-service based microservice for converting IP address to hostname 00026 * 00027 * \module webservices 00028 * 00029 * \since pre-2.1 00030 * 00031 * \author Arcot Rajasekar 00032 * \date 2008-05 00033 * 00034 * \brief This microservice returns host name and details given an IP address, 00035 * using the web service provided by http://ws.fraudlabs.com/. It executes a web 00036 * service to convert an IP address to a location. 00037 * 00038 * \usage See clients/icommands/test/rules3.0/ 00039 * 00040 * \param[in] inIpParam - This msParam is of type STR_MS_T inputs an ip-address. 00041 * \param[in] inLocParam - This msParam is of type STR_MS_T is a license string provided by http://ws.fraudlabs.com/ 00042 * \param[out] outLocParam - This msParam is of type STR_MS_T which is a host location information 00043 * \param[in,out] rei - The RuleExecInfo structure that is automatically 00044 * handled by the rule engine. The user does not include rei as a 00045 * parameter in the rule invocation. 00046 * 00047 * \DolVarDependence none 00048 * \DolVarModified none 00049 * \iCatAttrDependence none 00050 * \iCatAttrModified none 00051 * \sideeffect none 00052 * 00053 * \return integer 00054 * \retval 0 on success 00055 * \pre none 00056 * \post none 00057 * \sa none 00058 **/ 00059 int 00060 msiIp2location(msParam_t* inIpParam, msParam_t* inLocParam, msParam_t* outLocParam, ruleExecInfo_t* rei ) 00061 { 00062 00063 struct soap *soap = soap_new(); 00064 struct _ns1__IP2Location ip; 00065 struct _ns1__IP2LocationResponse loc; 00066 char response[10000]; 00067 RE_TEST_MACRO( " Calling msiIp2location" ); 00068 00069 ip.IP = (char *) inIpParam->inOutStruct; 00070 ip.LICENSE = (char *) inLocParam->inOutStruct; 00071 00072 soap_init(soap); 00073 soap_set_namespaces(soap, ip2location_namespaces); 00074 if (soap_call___ns1__IP2Location(soap, NULL, NULL, &ip, &loc) == SOAP_OK) { 00075 sprintf(response,"%s",soap->buf); 00076 fillMsParam( outLocParam, NULL, 00077 STR_MS_T, response, NULL ); 00078 free(loc.IP2LocationResult); 00079 return(0); 00080 } 00081 else { 00082 sprintf(response,"Error in execution of msiIp2location::%s\n",soap->buf); 00083 fillMsParam( outLocParam, NULL, 00084 STR_MS_T, response, NULL ); 00085 return(0); 00086 } 00087 } 00088