Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_WEB, (void **)(&pMe->m_pIWeb));
CALLBACK_Init(&pMe->m_Callback,WebReadCB,pMe);
if (SUCCESS == ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_SOURCEUTIL,(void **)&pisu))
{
if(ISOURCEUTIL_SourceFromMemory(pisu,pszPostData,STRLEN(pszPostData), NULL, NULL,&pMe->m_pISource)==SUCCESS)
{
IWEB_GetResponse(pMe->m_pIWeb,(pMe->m_pIWeb,&pMe->m_pIWebResp,&pMe->m_Callback,"http://192.168.0.91:8080/GLMS/welcome",WEBOPT_HEADER, "X-Method: POST\r\n",WEBOPT_METHOD,"POST",WEBOPT_BODY,pMe->m_pISource,WEBOPT_CONTENTLENGTH, STRLEN(pszPostData),WEBOPT_END));
}

above code im using it for posting web request server, its giving problem when i post multiple request, access violation error im getting, near iweb getresponse api
imunable to understand da problem.. first request is posted successfully every time but when i try to send multiple request im unable tooooo

May be you not release all resources before second request...
Need bit more code.

May be you not release all resources before second request...
Need bit more code.

Prog wrote:May be you not release all resources before second request...
Need bit more code.
void http_webrequest(webs* pMe)
{
ISourceUtil *pisu=NULL;
int i=0;
//pMe->m_pISource=NULL;
pMe->m_pIWeb=NULL;
pMe->m_pIWebResp=NULL;
if (!IsNetAvailable(pMe))
{
WebCleanup(pMe);
return;
}
if(!pMe->m_pIWeb && ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_WEB, (void **)(&pMe->m_pIWeb))!= SUCCESS)
{
WebCleanup(pMe);
return;
}
CALLBACK_Init(&pMe->m_Callback,WebReadCB,pMe);
if (SUCCESS == ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_SOURCEUTIL,(void **)&pisu))
{
if(ISOURCEUTIL_SourceFromMemory(pisu,pszPostData,STRLEN(pszPostData), NULL, NULL,&pMe->m_pISource)==SUCCESS)
{
if(first==TRUE)
{
first=FALSE;
IWEB_GetResponse(pMe->m_pIWeb,(pMe->m_pIWeb,&pMe->m_pIWebResp,&pMe->m_Callback,"http://192.168.0.91:8080/GLMS/welcome",WEBOPT_HEADER, "X-Method: POST\r\n",WEBOPT_METHOD,"POST",WEBOPT_BODY,pMe->m_pISource,WEBOPT_CONTENTLENGTH, STRLEN(pszPostData),WEBOPT_END));
}
else
{
IWEB_GetResponse(pMe->m_pIWeb,(pMe->m_pIWeb,&pMe->m_pIWebResp,&pMe->m_Callback,"http://192.168.0.91:8080/GLMS/welcome",WEBOPT_HEADER,pMe->m_headerbuffer,WEBOPT_STATUSHANDLER, WebAction_Status,WEBOPT_METHOD,"POST",WEBOPT_BODY,pMe->m_pISource,WEBOPT_CONTENTLENGTH, STRLEN(pszPostData),WEBOPT_END));
}
}
}
}
static void WebReadCB(void* cxt)
{
webs* pMe = (webs*)cxt;
WebRespInfo* pWebRespInfo = IWEBRESP_GetInfo(pMe->m_pIWebResp);
int ByteCount,i,c;
char *code= (char*) MALLOC(sizeof(char));
char *ret_code= (char*) MALLOC(sizeof(char));
char *retcode= (char*) MALLOC(sizeof(char));
char *err_code[12]={"401","409","403","531","603","422","543","503","505","200","600","500"};
ISource* pISource = pWebRespInfo->pisMessage;
if(pszRecData)
FREE(pszRecData);
pszRecData=(char*) MALLOC (sizeof(char));
if (pWebRespInfo && WEB_ERROR_SUCCEEDED(pWebRespInfo->nCode))
{
if (pWebRespInfo->nCode==200)
{
ByteCount = ISOURCE_Read(pISource,pszRecData, sizeof(char)*1500);
switch (ByteCount)
{
case ISOURCE_WAIT:
ISOURCE_Readable(pISource, &pMe->m_Callback);
return;
case ISOURCE_ERROR:
break;
case ISOURCE_END:
if (pMe->m_pIWebResp!=NULL)
{
IWEBRESP_Release(pMe->m_pIWebResp);
pMe->m_pIWebResp = NULL;
}
WebCleanup(pMe);
break;
default:
if (ByteCount>0)
{
code="";
c=6;i=0;
ret_code=STRISTR(pszRecData,code);
if(ret_code!=NULL)
{
while (ret_code[c]!='<')
{
retcode[i]=ret_code[c];c++;i++;
}
retcode[i]=NULL;
}
for (i=0;i<12;i++)
{
if(STRCMP(err_code[i],retcode)==0)
{
break;
}
}
}
ISOURCE_Readable(pISource, &pMe->m_Callback);
//return; // added on 28_6_07
break; // remove later
}
}
// CALLBACK_Cancel(&pMe->m_Callback);
// ReleaseObj((void **)&pMe->m_pIWebResp); // let response go
switch(i)
{
case 0: //Further authorization needed to use the server
DisplayOutput((IApplet *)pMe,28,"Further authorization needed to use the server:401", MAKE_RGB(0, 0, 0));
break;
case 1://invalid password
DisplayOutput((IApplet *)pMe,28,"Invalid password:409", MAKE_RGB(0, 0, 0));
break;
case 2://the particular user is not allowed to use the server
DisplayOutput((IApplet *)pMe,28,"The particular user is not allowed to use the server:403", MAKE_RGB(0, 0, 0));
break;
case 3://Unknown user
DisplayOutput((IApplet *)pMe,28,"Unknown user:531", MAKE_RGB(0, 0, 0));
break;
case 4://Already logged in
DisplayOutput((IApplet *)pMe,28,"Already logged in:603", MAKE_RGB(0, 0, 0));
break;
case 5://Session id,user id and client id not matching
DisplayOutput((IApplet *)pMe,28,"Session id,user id and client id not matching:422", MAKE_RGB(0, 0, 0));
break;
case 6://No matches Digest Scheme supported
DisplayOutput((IApplet *)pMe,28,"No matches Digest Scheme supported:543", MAKE_RGB(0, 0, 0));
break;
case 7://Service unavailable
DisplayOutput((IApplet *)pMe,28,"Service unavailable:503", MAKE_RGB(0, 0, 0));
break;
case 8:// Version not supported
DisplayOutput((IApplet *)pMe,28,"Version not supported:505", MAKE_RGB(0, 0, 0));
break;
case 9://Successfully logged in
if (prev_fun_id==1)//Came from Login
{
login_resp_action(pMe);
}
else if(prev_fun_id==2)// Reading the response from the server for contact list request
{
DisplayOutput((IApplet *)pMe,28,"Successfully logged in:200", MAKE_RGB(0, 0, 0));
}
else if (prev_fun_id==3)
{
retrive_contact_list_response(pMe);
}
break;
case 10: // Session Expired
DisplayOutput((IApplet *)pMe,28,"Session Expired:600", MAKE_RGB(0, 0, 0));
break;
case 11://Internal Server Error
DisplayOutput((IApplet *)pMe,28,"Internal Server Error:500", MAKE_RGB(0, 0, 0));
break;
default:
if (prev_fun_id==2)
{
contact_list_resp(pMe);
//DisplayOutput((IApplet *)pMe,28,"Contact list response", MAKE_RGB(0, 0, 0));
}
else
DisplayOutput((IApplet *)pMe,28,"Unknown Error", MAKE_RGB(0, 0, 0));
break;
}
}
FREE(code);
FREE(ret_code);
FREE(retcode);

static void WebCleanup(webs *pMe)
{
if(&pMe->m_Callback!=NULL)
CALLBACK_Cancel(&pMe->m_Callback);
pMe->m_pIWebResp = NULL;
if (pMe->m_pIWeb!=NULL)
{
IWEB_Release(pMe->m_pIWeb);
pMe->m_pIWeb = NULL;
}
}
befor each and every req i use webcleanup fun to free resources

Prog wrote:May be you not release all resources before second request...
Need bit more code.
void http_webrequest(webs* pMe)
{
ISourceUtil *pisu=NULL;
int i=0;
//pMe->m_pISource=NULL;
pMe->m_pIWeb=NULL;
pMe->m_pIWebResp=NULL;
if (!IsNetAvailable(pMe))
{
WebCleanup(pMe);
return;
}
if(!pMe->m_pIWeb && ISHELL_CreateInstance( pMe->a.m_pIShell, AEECLSID_WEB, (void **)(&pMe->m_pIWeb))!= SUCCESS)
{
WebCleanup(pMe);
return;
}
CALLBACK_Init(&pMe->m_Callback,WebReadCB,pMe);
if (SUCCESS == ISHELL_CreateInstance(pMe->a.m_pIShell,AEECLSID_SOURCEUTIL,(void **)&pisu))
{
if(ISOURCEUTIL_SourceFromMemory(pisu,pszPostData,STRLEN(pszPostData), NULL, NULL,&pMe->m_pISource)==SUCCESS)
{
if(first==TRUE)
{
first=FALSE;
IWEB_GetResponse(pMe->m_pIWeb,(pMe->m_pIWeb,&pMe->m_pIWebResp,&pMe->m_Callback,"http://192.168.0.91:8080/GLMS/welcome",WEBOPT_HEADER, "X-Method: POST\r\n",WEBOPT_METHOD,"POST",WEBOPT_BODY,pMe->m_pISource,WEBOPT_CONTENTLENGTH, STRLEN(pszPostData),WEBOPT_END));
}
else
{
IWEB_GetResponse(pMe->m_pIWeb,(pMe->m_pIWeb,&pMe->m_pIWebResp,&pMe->m_Callback,"http://192.168.0.91:8080/GLMS/welcome",WEBOPT_HEADER,pMe->m_headerbuffer,WEBOPT_STATUSHANDLER, WebAction_Status,WEBOPT_METHOD,"POST",WEBOPT_BODY,pMe->m_pISource,WEBOPT_CONTENTLENGTH, STRLEN(pszPostData),WEBOPT_END));
}
}
}
}
static void WebReadCB(void* cxt)
{
webs* pMe = (webs*)cxt;
WebRespInfo* pWebRespInfo = IWEBRESP_GetInfo(pMe->m_pIWebResp);
int ByteCount,i,c;
char *code= (char*) MALLOC(sizeof(char));
char *ret_code= (char*) MALLOC(sizeof(char));
char *retcode= (char*) MALLOC(sizeof(char));
char *err_code[12]={"401","409","403","531","603","422","543","503","505","200","600","500"};
ISource* pISource = pWebRespInfo->pisMessage;
if(pszRecData)
FREE(pszRecData);
pszRecData=(char*) MALLOC (sizeof(char));
if (pWebRespInfo && WEB_ERROR_SUCCEEDED(pWebRespInfo->nCode))
{
if (pWebRespInfo->nCode==200)
{
ByteCount = ISOURCE_Read(pISource,pszRecData, sizeof(char)*1500);
switch (ByteCount)
{
case ISOURCE_WAIT:
ISOURCE_Readable(pISource, &pMe->m_Callback);
return;
case ISOURCE_ERROR:
break;
case ISOURCE_END:
if (pMe->m_pIWebResp!=NULL)
{
IWEBRESP_Release(pMe->m_pIWebResp);
pMe->m_pIWebResp = NULL;
}
WebCleanup(pMe);
break;
default:
if (ByteCount>0)
{
code="";
c=6;i=0;
ret_code=STRISTR(pszRecData,code);
if(ret_code!=NULL)
{
while (ret_code[c]!='<')
{
retcode[i]=ret_code[c];c++;i++;
}
retcode[i]=NULL;
}
for (i=0;i<12;i++)
{
if(STRCMP(err_code[i],retcode)==0)
{
break;
}
}
}
ISOURCE_Readable(pISource, &pMe->m_Callback);
//return; // added on 28_6_07
break; // remove later
}
}
// CALLBACK_Cancel(&pMe->m_Callback);
// ReleaseObj((void **)&pMe->m_pIWebResp); // let response go
switch(i)
{
case 0: //Further authorization needed to use the server
DisplayOutput((IApplet *)pMe,28,"Further authorization needed to use the server:401", MAKE_RGB(0, 0, 0));
break;
case 1://invalid password
DisplayOutput((IApplet *)pMe,28,"Invalid password:409", MAKE_RGB(0, 0, 0));
break;
case 2://the particular user is not allowed to use the server
DisplayOutput((IApplet *)pMe,28,"The particular user is not allowed to use the server:403", MAKE_RGB(0, 0, 0));
break;
case 3://Unknown user
DisplayOutput((IApplet *)pMe,28,"Unknown user:531", MAKE_RGB(0, 0, 0));
break;
case 4://Already logged in
DisplayOutput((IApplet *)pMe,28,"Already logged in:603", MAKE_RGB(0, 0, 0));
break;
case 5://Session id,user id and client id not matching
DisplayOutput((IApplet *)pMe,28,"Session id,user id and client id not matching:422", MAKE_RGB(0, 0, 0));
break;
case 6://No matches Digest Scheme supported
DisplayOutput((IApplet *)pMe,28,"No matches Digest Scheme supported:543", MAKE_RGB(0, 0, 0));
break;
case 7://Service unavailable
DisplayOutput((IApplet *)pMe,28,"Service unavailable:503", MAKE_RGB(0, 0, 0));
break;
case 8:// Version not supported
DisplayOutput((IApplet *)pMe,28,"Version not supported:505", MAKE_RGB(0, 0, 0));
break;
case 9://Successfully logged in
if (prev_fun_id==1)//Came from Login
{
login_resp_action(pMe);
}
else if(prev_fun_id==2)// Reading the response from the server for contact list request
{
DisplayOutput((IApplet *)pMe,28,"Successfully logged in:200", MAKE_RGB(0, 0, 0));
}
else if (prev_fun_id==3)
{
retrive_contact_list_response(pMe);
}
break;
case 10: // Session Expired
DisplayOutput((IApplet *)pMe,28,"Session Expired:600", MAKE_RGB(0, 0, 0));
break;
case 11://Internal Server Error
DisplayOutput((IApplet *)pMe,28,"Internal Server Error:500", MAKE_RGB(0, 0, 0));
break;
default:
if (prev_fun_id==2)
{
contact_list_resp(pMe);
//DisplayOutput((IApplet *)pMe,28,"Contact list response", MAKE_RGB(0, 0, 0));
}
else
DisplayOutput((IApplet *)pMe,28,"Unknown Error", MAKE_RGB(0, 0, 0));
break;
}
}
FREE(code);
FREE(ret_code);
FREE(retcode);

static void WebCleanup(webs *pMe)
{
if(&pMe->m_Callback!=NULL)
CALLBACK_Cancel(&pMe->m_Callback);
pMe->m_pIWebResp = NULL;
if (pMe->m_pIWeb!=NULL)
{
IWEB_Release(pMe->m_pIWeb);
pMe->m_pIWeb = NULL;
}
}
befor each and every req i use webcleanup fun to free resources

try
IWEBRESP_Release(pMe->m_pIWebResp);
instead of
pMe->m_pIWebResp = NULL;

try
IWEBRESP_Release(pMe->m_pIWebResp);
instead of
pMe->m_pIWebResp = NULL;

Hi Guys!
I think we can not send multiple post request one after anothr.
Try to wait for control returns to callback then send next request.
BR

Hi Guys!
I think we can not send multiple post request one after anothr.
Try to wait for control returns to callback then send next request.
BR