Msxml2.XMLHTTP关于POST方式的问题
xmlhttp.open("POST", "somepage", true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(postContent);
这个xmlhttp.send是干什么用的,把name=XXXX&email=XXXX@yahoo.com.cn以XML的格式比如<name>XXXXX</name><email>XXXXX@yahoo.com.cn</email>这样发送到服务器?
我想发送这样一个xml格式的订单
<orders>
<order>
<product>
<name></name>
<count></count>
</product>
</order>
<order>
</order>
</orders>
应该怎么写postcontent呢?
相关推荐
在VC中使用XMLHTTP
主 题: 在VC中使用XMLHTTP,怎样初始化,怎样建立连接?在线等。 我的一段代码在.NET中用C#已经调通,我想搬到VC++ 6.0上,但不知道任何各种写法规则。 C# 中为: MSXML2.XMLHTTP xmlHttp_ = new XMLHTTP(); xmlHttp_.open("PROPFIND", serverUrl, false, username, password); xmlHttp_.send(null); 放到VC++ 6.0 中应为什么? 以下是我写的,但运行出错。 #import "msxml4.dll" using namespace MSXML2; HRESULT hr; //MSXML2::IXMLHTTPRequest pIXMLHttpRequest; CString serverUrl ="http://services.msn.com/svcs/hotmail/httpmail.asp"; MSXML2::IXMLHTTPRequestPtr pIXMLHttpRequest; pIXMLHttpRequest.CreateInstance("Msxml2.XMLHTTP.4.0"); if (pIXMLHttpRequest==NULL) AfxMessageBox("pIXMLHttpRequest error"); try { // Create XMLHttpRequest object and initialize pIXMLHttpRequest. hr = pIXMLHttpRequest->open(_bstr_t(_T("PROPFIND")), _bstr_t(_T(serverUrl)), _variant_t(VARIANT_FALSE), _variant_t("test5_12"), _variant_t("1234567")); if(SUCCEEDED(hr)) ::MessageBox(NULL, _T("Success !"), _T(""), MB_OK); } catch(...) { //DisplayErrorToUser(); AfxMessageBox("error"); } 在调用方法open的时候出错! 回复人: masterz(www.fruitfruit.com) ( ) 信誉:273 2003-06-10 21:34:02Z 得分:20 ? #import "msxml.dll" #import "msxml2.dll" using namespace MSXML2; int main(int argc, char* argv[]) { printf("Test of XMLHTTP by masterz!\n"); CoInitialize(NULL); try { IXMLHTTPRequestPtr xmlrequest; xmlrequest.CreateInstance("Msxml2.XMLHTTP"); _variant_t varp(false); xmlrequest->open(_bstr_t("GET"),_bstr_t("http://www.csdn.net/expert/topic/855/855052.xml?temp=.176037"),varp); xmlrequest->send(); BSTR bstrbody; xmlrequest->get_responseText(&bstrbody); _bstr_t bstrtbody(bstrbody); printf("%s\n",(LPCTSTR)bstrtbody); } catch (_com_error &e) { printf("Description = '%s'\n", (char*) e.Description()); } CoUninitialize(); printf("program end\n"); return 0; } ///////Post with XMLHTTP/////////////////////// #import "msxml.dll" #import "msxml2.dll" #include "Atlbase.h" using namespace MSXML2; int main(int argc, char* argv[]) { printf("Test of XMLHTTP by masterz!\n"); CoInitialize(NULL); try { IXMLHTTPRequestPtr xmlrequest; //xmlrequest.CreateInstance("Msxml2.XMLHTTP"); xmlrequest.CreateInstance(__uuidof(XMLHTTP)); CComVariant vFalse(FALSE); CComVariant vNull(NULL); xmlrequest->open("POST", _bstr_t("http://211.157.102.21/member/logon.asp"),vFalse,vNull,vNull); xmlrequest->setRequestHeader("Content-Type:","application/x-www-form-urlencoded"); _bstr_t bsdata("name=xxx&pass=xxx&type=1");//use your login name and password xmlrequest->send(_variant_t(bsdata)); BSTR bstrbody; xmlrequest->get_responseText(&bstrbody); _bstr_t bstrtbody(bstrbody); printf("%s\n",(LPCTSTR)bstrtbody); //MessageBox(0,bstrtbody,"",MB_OK); } catch (_com_error &e) { printf("Description = '%s'\n", (char*) e.Description()); } CoUninitialize(); printf("program end\n"); return 0; }
Excel vba使用XMLHTTP进行异步下载的演示
大文件下载不再卡机。XMLHTTP的OnReadyStateChange事件进行异步下载的演示。例子是下载一个8M的mp3文件
VB6Get和POST请求异步处理请求
异步处理主球,能有效地解决xmlhttp组件卡死问题
VB的POST代码示例
VB的POST代码示例VB的POST代码示例VB的POST代码示例
ASP利用XMLHTTP实现表单提交以及cookies的发送的代码
确实,如果在原网站如果存在表单提交或cookies的验证,对于ASP来说,不使用基于SOCKET的组件就难以完成,其实,XMLHTTP的另外两个方法被我们忽略了,而这正是问题的关键。 下面首先来说说这个方法 1。.send() 由于流行的小偷是使用的GET而不是POST来传送数据,所以很多人忽略了这个方法,而使用SEND发送数据也很简单,就是SEND(“内容”),可是, 发送表单就不是这么简单,因为你发送的表单如果是中文的话,就要牵扯到编码的问题了。 首先,你在OPEN 时要确定是用POST 即 .open(“POST”,地址,是否异步) 。


