VS2008如何建立非托管项目

tiger_tiger_tiger_ 2009-11-24 12:08:31
以前没用过webserver,现在的项目要我调用webserver接口,并且指定要用非托管,可是VS2008上好像不能建立非托管项目,哪位大哥知道怎么用吗?这方面才接触,所以最好有具体的操作方法!谢谢了!
...全文
1180 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
M_595280815 2012-08-07
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

引用 3 楼 tr0j4n 的回复:
非托管可以这么调WebService

C/C++ code
#import"msxml4.dll"usingnamespace MSXML2;

#import"C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP30.dll" \
……
[/Quote]
我也是这个问题唉 有人知道怎么回事吗
chenjiawei007 2010-08-15
  • 打赏
  • 举报
回复
但是我就是用3L的方法去访问webservice的 ,但是会遇到问题:webservice没法接受我传的参数
chenjiawei007 2010-08-15
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 tiger_tiger_tiger_ 的回复:]
引用 3 楼 tr0j4n 的回复:
非托管可以这么调WebService

C/C++ code
#import"msxml4.dll"usingnamespace MSXML2;

#import"C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP30.dll" \
exclude("IStream","……
[/Quote]



导入的文件需要 重新再输入一遍 不能直接复制,
比如include 和 import 需要自己手动输入
jcrsjcrs 2010-03-12
  • 打赏
  • 举报
回复
顶!!!!!!!!!!!!
wshcdr 2009-11-26
  • 打赏
  • 举报
回复
UP, ATL Server是比较奇怪
zyq5945 2009-11-24
  • 打赏
  • 举报
回复
网上看到vs2008好像真的不支持webserver了。
http://www.vckbase.com/document/viewdoc/?id=1696
oyljerry 2009-11-24
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 tiger_tiger_tiger_ 的回复:]
引用 6 楼 xwsn007 的回复:
vc.net:
http://www.vckbase.com/document/viewdoc/?id=1696
这个简单

vc6:
只能用MSSOAP30了

这个是2005或以前版本吧,2008上非托管的时候web引用是用不了的
[/Quote]
用其他第三方SOAP等库
tiger_tiger_tiger_ 2009-11-24
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 xwsn007 的回复:]
vc.net:
http://www.vckbase.com/document/viewdoc/?id=1696
这个简单

vc6:
只能用MSSOAP30了
[/Quote]
这个是2005或以前版本吧,2008上非托管的时候web引用是用不了的
jameshooo 2009-11-24
  • 打赏
  • 举报
回复
VC2005才支持非托管调用WebService,以后的版本取消了,原因是微软把这块内容开源了,官方不再支持,但是还在由个人维护,你可以在网上下载源码(包括项目向导等),实际上等同于恢复2005中的功能。说实话,微软的这个库做的不太好,架构弹性不够,对标准支持不全,不能跟随时代潮流,形同鸡肋,还不如找个第三方SOAP库。

这个库叫AtlServer,可以到微软的开源社区 codeplex 中去下载。
xwsn007 2009-11-24
  • 打赏
  • 举报
回复
vc.net:
http://www.vckbase.com/document/viewdoc/?id=1696
这个简单

vc6:
只能用MSSOAP30了
tiger_tiger_tiger_ 2009-11-24
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 tr0j4n 的回复:]
非托管可以这么调WebService

C/C++ code
#import"msxml4.dll"usingnamespace MSXML2;

#import"C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP30.dll" \
exclude("IStream","ISequentialStream","_LARGE_INTEGER", \"_ULARGE_INTEGER","tagSTATSTG","_FILETIME")usingnamespace MSSOAPLib30;void CallService()
{try{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;// Connect to the serviceif(FAILED(Connector.CreateInstance(__uuidof(HttpConnector30)))){
AfxMessageBox("Create HTTP Connector Failed!");return;
}//Connector->Property["EndPointURL"] = "http://www.soyoyo.cn/WebService/SoyoyoService.asmx?WSDL"; Connector->Property["EndPointURL"]="http://phs.cnool.net/webserver/spserver_ordersend.asmx";
Connector->Connect();// Begin message//Connector->Property["SoapAction"] = "http://tempuri.org/GetFreeSendRemain"; Connector->Property["SoapAction"]="http://tempuri.org/ordersend";
Connector->BeginMessage();// Create the SoapSerializerif(FAILED(Serializer.CreateInstance(__uuidof(SoapSerializer30)))){
AfxMessageBox("Create SOAP Serializer Failed!");return;
}// Connect the serializer to the input stream of the connector Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));// Build the SOAP Message Serializer->StartEnvelope("","","");
Serializer->StartBody("");//Serializer->StartElement("GetFreeSendRemain","http://tempuri.org/","","");// Serializer->StartElement("ordersend","http://tempuri.org/","","");// Serializer->StartElement("UserName","","","");// Serializer->WriteString("krh2001");// Serializer->EndElement();// Serializer->StartElement("Password","","","");// Serializer->WriteString("kong2000");// Serializer->EndElement();// Serializer->StartElement("username","", "","");// Serializer->WriteString("nhgame");// Serializer->EndElement();// Serializer->StartElement("content","", "","");// Serializer->WriteString("你的初始密码为:s89R4x37。请保管好自己的密码。");// Serializer->EndElement();// Serializer->StartElement("destpohne","", "","");// Serializer->WriteString("057466511283");// Serializer->EndElement();// Serializer->StartElement("shortcode","", "","");// Serializer->WriteString("61");// Serializer->EndElement();// Serializer->StartElement("servicecode","", "","");// Serializer->WriteString("f010");// Serializer->EndElement();//// Serializer->EndElement();char buf[4096];
sprintf(buf, c_xml,"你的初始密码为:s89R4x37。请保管好自己的密码。","057466511283");
Serializer->WriteXml(buf);

Serializer->EndBody();
Serializer->EndEnvelope();// Send the message to the web service Connector->EndMessage();// Let us read the responseif(FAILED(Reader.CreateInstance(__uuidof(SoapReader30)))){
AfxMessageBox("Create SOAP Reader Failed!");return;
}// Connect the reader to the output stream of the connector Reader->Load(_variant_t((IUnknown*)Connector->OutputStream),"");// Display the result// char buf[4096];try{
IXMLDOMElementPtr elm= Reader->RpcResult;if(elm->hasChildNodes ())
{
IXMLDOMNodeListPtr nodes= elm->childNodes;for(int i=0; i< nodes->length;++i)
{
sprintf(buf,"%s = %s", (constchar*) nodes->item[i]->nodeName,
(constchar*)nodes->item[i]->text);
AfxMessageBox(buf);
}
}// while(elm){// sprintf(buf, "Answer: \n%s\n", (const char *)elm->xml);// AfxMessageBox(buf);// elm = elm->nextSibling;/// sprintf(buf, "Answer: %s\n", (const char *)Reader->RpcResult->nextSibling->nextSibling->xml);// AfxMessageBox(buf);// } }catch(_com_error& ce)
{
CString str;
str.Format("COM Error :(%08X)%s", ce.Error(), ce.ErrorMessage());
AfxMessageBox(str);

}
}catch(_com_error& ce)
{
CString str;
str.Format("COM Error :(%08X)%s", ce.Error(), ce.ErrorMessage());
AfxMessageBox(str);return;
}
}
[/Quote]
我把头文件加入时,系统报错“error C2872: “IXMLDOMNode”: 不明确的符号”,不知道这是怎么回事?
tiger_tiger_tiger_ 2009-11-24
  • 打赏
  • 举报
回复
[Quote=引用楼主 tiger_tiger_tiger_ 的回复:]
以前没用过webserver,现在的项目要我调用webserver接口,并且指定要用非托管,可是VS2008上好像不能建立非托管项目,哪位大哥知道怎么用吗?这方面才接触,所以最好有具体的操作方法!谢谢了!
[/Quote]
这个我看过了,VS2008下如果不选择托管的话,那个“添加web引用”是失活状态,用不了的!
MoXiaoRab 2009-11-24
  • 打赏
  • 举报
回复
非托管可以这么调WebService


#import "msxml4.dll"
using namespace MSXML2;

#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP30.dll" \
exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;



void CallService()
{
try{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;

// Connect to the service
if(FAILED(Connector.CreateInstance(__uuidof(HttpConnector30)))){
AfxMessageBox("Create HTTP Connector Failed!");
return;
}
//Connector->Property["EndPointURL"] = "http://www.soyoyo.cn/WebService/SoyoyoService.asmx?WSDL";
Connector->Property["EndPointURL"] = "http://phs.cnool.net/webserver/spserver_ordersend.asmx";
Connector->Connect();

// Begin message
//Connector->Property["SoapAction"] = "http://tempuri.org/GetFreeSendRemain";
Connector->Property["SoapAction"] = "http://tempuri.org/ordersend";
Connector->BeginMessage();

// Create the SoapSerializer
if(FAILED(Serializer.CreateInstance(__uuidof(SoapSerializer30)))){
AfxMessageBox("Create SOAP Serializer Failed!");
return;
}

// Connect the serializer to the input stream of the connector
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

// Build the SOAP Message
Serializer->StartEnvelope("","","");
Serializer->StartBody("");
//Serializer->StartElement("GetFreeSendRemain","http://tempuri.org/","","");
// Serializer->StartElement("ordersend","http://tempuri.org/","","");
// Serializer->StartElement("UserName","","","");
// Serializer->WriteString("krh2001");
// Serializer->EndElement();
// Serializer->StartElement("Password","","","");
// Serializer->WriteString("kong2000");
// Serializer->EndElement();

// Serializer->StartElement("username","", "","");
// Serializer->WriteString("nhgame");
// Serializer->EndElement();
// Serializer->StartElement("content","", "","");
// Serializer->WriteString("你的初始密码为:s89R4x37。请保管好自己的密码。");
// Serializer->EndElement();
// Serializer->StartElement("destpohne","", "","");
// Serializer->WriteString("057466511283");
// Serializer->EndElement();
// Serializer->StartElement("shortcode","", "","");
// Serializer->WriteString("61");
// Serializer->EndElement();
// Serializer->StartElement("servicecode","", "","");
// Serializer->WriteString("f010");
// Serializer->EndElement();
//
// Serializer->EndElement();
char buf[4096];
sprintf(buf, c_xml, "你的初始密码为:s89R4x37。请保管好自己的密码。", "057466511283");
Serializer->WriteXml(buf);

Serializer->EndBody();
Serializer->EndEnvelope();
// Send the message to the web service
Connector->EndMessage();

// Let us read the response
if(FAILED(Reader.CreateInstance(__uuidof(SoapReader30)))){
AfxMessageBox("Create SOAP Reader Failed!");
return;
}

// Connect the reader to the output stream of the connector
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");

// Display the result
// char buf[4096];
try{
IXMLDOMElementPtr elm = Reader->RpcResult;
if(elm->hasChildNodes ())
{
IXMLDOMNodeListPtr nodes = elm->childNodes;
for(int i = 0; i < nodes->length; ++i)
{
sprintf(buf, "%s = %s", (const char*) nodes->item[i]->nodeName,
(const char*)nodes->item[i]->text);
AfxMessageBox(buf);
}
}
// while(elm){
// sprintf(buf, "Answer: \n%s\n", (const char *)elm->xml);
// AfxMessageBox(buf);
// elm = elm->nextSibling;
/// sprintf(buf, "Answer: %s\n", (const char *)Reader->RpcResult->nextSibling->nextSibling->xml);
// AfxMessageBox(buf);
// }
}
catch(_com_error& ce)
{
CString str;
str.Format("COM Error :(%08X)%s", ce.Error(), ce.ErrorMessage());
AfxMessageBox(str);

}
}
catch(_com_error& ce)
{
CString str;
str.Format("COM Error :(%08X)%s", ce.Error(), ce.ErrorMessage());
AfxMessageBox(str);
return;
}
}
MoXiaoRab 2009-11-24
  • 打赏
  • 举报
回复
[Quote=引用楼主 tiger_tiger_tiger_ 的回复:]
以前没用过webserver,现在的项目要我调用webserver接口,并且指定要用非托管,可是VS2008上好像不能建立非托管项目,哪位大哥知道怎么用吗?这方面才接触,所以最好有具体的操作方法!谢谢了!
[/Quote]
建议非托管项目还不简单么,直接创建MFC或是Win32么

3,248

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧