A
Agam Mehta
Hi,
Everything works fine with ixmlhttprequest. It gives me "access
violation" only when i am trying to release it from the memory (i.e
pXMLHttpReq->Release()).
Below is my code.
//////////////////////////////////////////////////////////////////////////
::CoInitialize(NULL);
// Variables.
bstr_t sUrl = "http://localhost/test.xml";
bstr_t sMethod = "GET";
_variant_t vUser = L"USERNAME";
_variant_t vPassword = L"PASSWORD";
_variant_t vAsync = (bool)FALSE;
long lStatus = 0;
BSTR bstrResp;
BSTR bstrResponseText;
HRESULT hr;
IXMLHTTPRequestPtr pXMLHttpReq= NULL;
hr=pXMLHttpReq.CreateInstance("Msxml2.XMLHTTP.4.0");
if(hr != S_OK)
{
}
try
{
// Open the XMLHTTPRequest object with the DELETE method and
// specify that it will be sent asynchronously.
pXMLHttpReq->open(sMethod,
sUrl,
vAsync,
vUser,
vPassword);
pXMLHttpReq->send();
// Get the response status.
pXMLHttpReq->get_status(&lStatus);
// An error occurred on the server.
if(lStatus == 500)
{
}
else
{
// Display the response status.
// Display the response status text.
pXMLHttpReq->get_statusText(&bstrResp);
// Display the response text.
pXMLHttpReq->get_responseText(&bstrResponseText);
}
// Release the memory.
pXMLHttpReq->Release(); //THIS IS WHERE I GET ACCESS VIOLATION ERROR
}
catch(_com_error &e)
{
// Display the error information.
// Release the memory.
pXMLHttpReq->Release(); //THIS IS WHERE I GET ACCESS VIOLATION
ERROR
return 1;
}
CoUninitialize();
//////////////////////////////////////////////////////////////////////////
I have been trying to solve this for a long time but am not able to
find answer to it. Please help . I am using Ms Visual Studio 6.0 sp6.
Thanks for your help.
Agam Mehta
Everything works fine with ixmlhttprequest. It gives me "access
violation" only when i am trying to release it from the memory (i.e
pXMLHttpReq->Release()).
Below is my code.
//////////////////////////////////////////////////////////////////////////
::CoInitialize(NULL);
// Variables.
bstr_t sUrl = "http://localhost/test.xml";
bstr_t sMethod = "GET";
_variant_t vUser = L"USERNAME";
_variant_t vPassword = L"PASSWORD";
_variant_t vAsync = (bool)FALSE;
long lStatus = 0;
BSTR bstrResp;
BSTR bstrResponseText;
HRESULT hr;
IXMLHTTPRequestPtr pXMLHttpReq= NULL;
hr=pXMLHttpReq.CreateInstance("Msxml2.XMLHTTP.4.0");
if(hr != S_OK)
{
}
try
{
// Open the XMLHTTPRequest object with the DELETE method and
// specify that it will be sent asynchronously.
pXMLHttpReq->open(sMethod,
sUrl,
vAsync,
vUser,
vPassword);
pXMLHttpReq->send();
// Get the response status.
pXMLHttpReq->get_status(&lStatus);
// An error occurred on the server.
if(lStatus == 500)
{
}
else
{
// Display the response status.
// Display the response status text.
pXMLHttpReq->get_statusText(&bstrResp);
// Display the response text.
pXMLHttpReq->get_responseText(&bstrResponseText);
}
// Release the memory.
pXMLHttpReq->Release(); //THIS IS WHERE I GET ACCESS VIOLATION ERROR
}
catch(_com_error &e)
{
// Display the error information.
// Release the memory.
pXMLHttpReq->Release(); //THIS IS WHERE I GET ACCESS VIOLATION
ERROR
return 1;
}
CoUninitialize();
//////////////////////////////////////////////////////////////////////////
I have been trying to solve this for a long time but am not able to
find answer to it. Please help . I am using Ms Visual Studio 6.0 sp6.
Thanks for your help.
Agam Mehta