locked
Webservice returning '&gt' and '&lt' in place of angle brackets when called using MSXML:: IXMLHttpRequest RRS feed

  • Question

  • Hi,
    I am calling a webservice method using MSXML2::IXMLHttpRequest (msxml3.dll). I am sending a post request using the send method and then getting the response using "get_responseText". But this response is having data like "&gt", "&lt" etc. whereas it should return angle brackets in place of "&gt" and "&lt". When using MS SOAP the webservice is sending correct data.
     I am very new to this MSXML parser so I am not able get reason why I am getting this result.It would be great if someone could help me on this issue.

    This is the code that I am using to call the webservice:
    header file:
    #import "msxml3.dll" named_guids                //For connecting the webservice
    using namespace MSXML2;

    cpp file:

    TCHAR*  g_lpszSOAPReq = _T(
       "<?xml version='1.0' encoding='utf-8' ?>"
       "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>"
       "<SOAP-ENV:Body><method_name>"
       "<parameter>xyz</parameter></method_name></SOAP-ENV:Body></SOAP-ENV:Envelope>");

    MSXML2::IXMLHTTPRequestPtr HttpRequest;
        MSXML2::IXMLDOMDocument2Ptr  pXMLDoc;

        BOOL bRetVal = FALSE;
        CString URL = some URL ;

        CoInitialize(NULL);

        HRESULT hResult;      
        hResult = HttpRequest.CreateInstance("Microsoft.XMLHTTP");

        if ( FAILED(hResult) )
            AfxGetMainWnd()->PostMessage(WM_CLOSE);

        HRESULT hr = HttpRequest->open(_bstr_t("POST"),_bstr_t(URL),_variant_t(false));
        if (!(hr==S_OK))
        {
            AfxGetMainWnd()->PostMessageA(WM_CLOSE);
        }

        HttpRequest->setRequestHeader(_bstr_t("Content-Type"),_bstr_t("text/xml;charset=\"utf-8\""));
        HttpRequest->setRequestHeader(_bstr_t("SOAPAction"),_bstr_t("method_name"));

        hr = HttpRequest->send(_variant_t(g_lpszSOAPReq ));
        if (!(hr==S_OK))
        {
            AfxGetMainWnd()->PostMessageA(WM_CLOSE);
        }

        CString cstrResponse = "";
        BSTR bstr = cstrResponse.AllocSysString();
        hr = HttpRequest->get_responseText(&bstr);
        if (!(hr==S_OK))
        {
            AfxMessageBox("response could not be retrieved",MB_OK,0);
            AfxGetMainWnd()->PostMessageA(WM_CLOSE);
        }
    Thursday, March 18, 2010 4:14 AM

Answers

All replies