Hi,
I posted this in the VC forum earlier, but I think that I should have probably posted here instead, so... aplogies for the repost:
I'm trying to write a simple test app to connect to a .NET web service from a VC++ 6 application, but I keep on getting error 405 from CHttpFile::SendRequest(). I have .Net framework 1.1 installed.
Basically this is what I am doing...
From the web service test page the SOAP request is shown as:
POST /VerySimple/Service1.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/DoNothing"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<DoNothing xmlns="http://tempuri.org/" />
</soap:Body>
</soap:Envelope>
My code is:
static const TCHAR* g_lpszSOAPRequest =
_T("<soap:Envelope "
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
"xmlns:xsd='http://www.w3.org/2001/XMLSchema' "
"xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> "
"<soap:Body> "
" <DoNothing xmlns='http://tempuri.org/'> "
" </DoNothing> "
"</soap:Body> "
"</soap:Envelope>");
CInternetSession InetSess;
CHttpConnection * pHttpConn = InetSess.GetHttpConnection(_T("localhost"),
INTERNET_FLAG_NO_AUTO_REDIRECT,
80, NULL, NULL);
CHttpFile* pHttpFile =
pHttpConn->OpenRequest
(_T("POST"),
_T("/VerySimple/Service1.asmx HTTP/1.1"),
NULL, 1, NULL, "HTTP/1.1",
INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_EXISTING_CONNECT |
INTERNET_FLAG_DONT_CACHE |
INTERNET_FLAG_RELOAD);
CString strSOAPReq(g_lpszSOAPRequest);
DWORD dwRewLen = strSOAPReq.GetLength();
CString strHeaders;
strHeaders.Format(_T("Content-Type: text/xml; charset=utf-8\nContent-Length:%d"),
dwRewLen);
pHttpFile->AddRequestHeaders(strHeaders);
// 5. Send the request
pHttpFile->SendRequest(NULL, 0, (LPVOID)(LPCTSTR)strSOAPReq, dwRewLen);
// 6. Check the return HTTP Status Code
DWORD dwStatucCode = HTTP_STATUS_OK;
pHttpFile->QueryInfoStatusCode(dwStatucCode);
dwStatucCode always comes back as 405.
Can anyone see what I am doing wrong? Please Help!!!
Thanks