473,382 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

CHttpFile->SendRequest fails with 405

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
Jul 12 '06 #1
0 3604

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dmitriy A | last post by:
Hi, I have an problem that I've been struggling with for a week now and simply can not resolve. I have an MFC C++ application that sends a request to a servlet which sends back data...
0
by: Lee | last post by:
I am having a problem returning an image that I got from SQL Server from within an ASP page that got requested from a VC++ application. Specifically, within my application, I make an HTTP call to...
1
by: Chris | last post by:
Hello, I have a program that uses the CInternetSession and CHttpConnection mfc classes to register the program...it works for the majority of our customers, but a few have received errors, all...
0
by: Lasse Seten | last post by:
I have an MFC application trying to connect to my ASP.NET application through MFC classes CrfInternetSession and CHttpFile and functions OpenRequest and EndRequest. I am using HTTP POST and HTTP...
0
by: skysurf | last post by:
Hello, I have been placed on a new project involving development for Windows CE using Visual C++. I have to send an XML file via a SSL connection to a server followed by receiving a corresponding...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.