How to call Web Service?? | developer.brewmp.com How to call Web Service?? | developer.brewmp.com

Developer

How to call Web Service??

Forums:

Hi All,

I am new to BREW application development enviornment.

Can anyone please tell me how to call Web Service from my sample application or provide me an example for the same.

Thanks in Advance.

Go through the IWEB inter face IWEBRESP interface in rthe API refrence

Go through the IWEB inter face IWEBRESP interface in rthe API refrence

Thanks for the reply.
I have used IWeb & IWebResp interfaces to read an web page using "GET" method.
The problem which currently I am facing is to call a method of the web service.
Please guide me to resolve the problem.
Thanks

Thanks for the reply.
I have used IWeb & IWebResp interfaces to read an web page using "GET" method.
The problem which currently I am facing is to call a method of the web service.
Please guide me to resolve the problem.
Thanks

ankushthemaster wrote:Thanks for the reply.
I have used IWeb & IWebResp interfaces to read an web page using "GET" method.
The problem which currently I am facing is to call a method of the web service.
Please guide me to resolve the problem.
Thanks
Please refer to the URL below.
http://www.s-cradle.com/english/products/sophiaframework/reference/ref.S...
You can call a method of the web service with SophiaFramework UNIVERSE
Thanks.

ankushthemaster wrote:Thanks for the reply.
I have used IWeb & IWebResp interfaces to read an web page using "GET" method.
The problem which currently I am facing is to call a method of the web service.
Please guide me to resolve the problem.
Thanks
Please refer to the URL below.
http://www.s-cradle.com/english/products/sophiaframework/reference/ref.S...
You can call a method of the web service with SophiaFramework UNIVERSE
Thanks.

Hi,
I have created an sample application to call web service using "GET" method, the code is as folows:
static void GetWebStream(void* pData)
{
CWebServiceApp *pMe = (CWebServiceApp *)pData;
char *szPostHeader = NULL;
ISourceUtil *pUtil = NULL;
IPeek *ppeek = NULL;
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_WEB, (void **)&pMe->pIWeb);
CALLBACK_Init(&pMe->cb, WebCallback, pMe);
szPostHeader = MALLOC(200);
SPRINTF(szPostHeader, "Content-Type:text/xml; charset=utf-8\r\n");
IWEB_GetResponse(pMe->pIWeb, (pMe->pIWeb,
&pMe->pIWebResp,
&pMe->cb,
"http://webservices.iter.dk/calculator.asmx/Add?intA=100&intB=20",
WEBOPT_HEADER, szPostHeader,
WEBOPT_METHOD, "GET",
WEBOPT_HANDLERDATA, pMe,
//WEBOPT_HEADERHANDLER, EventHeader,
WEBOPT_COPYOPTS, TRUE,
WEBOPT_END));
FREE(szPostHeader);
//GetWebStream
static void WebCallback(void* pData)
{
CWebServiceApp *pMe = (CWebServiceApp *)pData;
WebRespInfo *info = NULL;
char *szString = MALLOC(2000);
int i = 0;
IFileMgr *pMgr = NULL;
info = IWEBRESP_GetInfo(pMe->pIWebResp);
CALLBACK_Init(&pMe->cb, WebReadable, pMe);
ISOURCE_Read(info->pisMessage, szString, 2000);
ISOURCE_Readable(info->pisMessage, &pMe->cb);
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FILEMGR, (void **)&pMgr);
if (!pMgr)
{
FREE(szString);
return;
} //if
IFILEMGR_Remove(pMgr, "test.txt");
pMe->pFile = IFILEMGR_OpenFile(pMgr, "test.txt", _OFM_CREATE);
IFILE_Write(pMe->pFile, szString, STRLEN(szString));
FREE(szString);
IFILEMGR_Release(pMgr);
return;
//WebCallback
static void WebReadable(void* pData)
{
CWebServiceApp *pMe = (CWebServiceApp *)pData;
WebRespInfo *info = NULL;
char *szString = MALLOC(2000);
info = IWEBRESP_GetInfo(pMe->pIWebResp);
CALLBACK_Init(&pMe->cb, WebReadable, pMe);
if (ISOURCE_Read(info->pisMessage, szString, 2000) > 0)
{
ISOURCE_Readable(info->pisMessage, &pMe->cb);
IFILE_Write(pMe->pFile, szString, STRLEN(szString));
}
else
{
IFILE_Release(pMe->pFile);
} //if
FREE(szString);
return;
//WebReadable
I would like to know how to call the web service using "POST" method.
Thanks :)

Hi,
I have created an sample application to call web service using "GET" method, the code is as folows:
static void GetWebStream(void* pData)
{
CWebServiceApp *pMe = (CWebServiceApp *)pData;
char *szPostHeader = NULL;
ISourceUtil *pUtil = NULL;
IPeek *ppeek = NULL;
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_WEB, (void **)&pMe->pIWeb);
CALLBACK_Init(&pMe->cb, WebCallback, pMe);
szPostHeader = MALLOC(200);
SPRINTF(szPostHeader, "Content-Type:text/xml; charset=utf-8\r\n");
IWEB_GetResponse(pMe->pIWeb, (pMe->pIWeb,
&pMe->pIWebResp,
&pMe->cb,
"http://webservices.iter.dk/calculator.asmx/Add?intA=100&intB=20",
WEBOPT_HEADER, szPostHeader,
WEBOPT_METHOD, "GET",
WEBOPT_HANDLERDATA, pMe,
//WEBOPT_HEADERHANDLER, EventHeader,
WEBOPT_COPYOPTS, TRUE,
WEBOPT_END));
FREE(szPostHeader);
//GetWebStream
static void WebCallback(void* pData)
{
CWebServiceApp *pMe = (CWebServiceApp *)pData;
WebRespInfo *info = NULL;
char *szString = MALLOC(2000);
int i = 0;
IFileMgr *pMgr = NULL;
info = IWEBRESP_GetInfo(pMe->pIWebResp);
CALLBACK_Init(&pMe->cb, WebReadable, pMe);
ISOURCE_Read(info->pisMessage, szString, 2000);
ISOURCE_Readable(info->pisMessage, &pMe->cb);
ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FILEMGR, (void **)&pMgr);
if (!pMgr)
{
FREE(szString);
return;
} //if
IFILEMGR_Remove(pMgr, "test.txt");
pMe->pFile = IFILEMGR_OpenFile(pMgr, "test.txt", _OFM_CREATE);
IFILE_Write(pMe->pFile, szString, STRLEN(szString));
FREE(szString);
IFILEMGR_Release(pMgr);
return;
//WebCallback
static void WebReadable(void* pData)
{
CWebServiceApp *pMe = (CWebServiceApp *)pData;
WebRespInfo *info = NULL;
char *szString = MALLOC(2000);
info = IWEBRESP_GetInfo(pMe->pIWebResp);
CALLBACK_Init(&pMe->cb, WebReadable, pMe);
if (ISOURCE_Read(info->pisMessage, szString, 2000) > 0)
{
ISOURCE_Readable(info->pisMessage, &pMe->cb);
IFILE_Write(pMe->pFile, szString, STRLEN(szString));
}
else
{
IFILE_Release(pMe->pFile);
} //if
FREE(szString);
return;
//WebReadable
I would like to know how to call the web service using "POST" method.
Thanks :)