C++如何调用WebService当然是非托管的.比如一个方法返回public class Test{ public int Id{get;set;}public string Title{get;set;}}怎么调用呀
解决方案 »
- 哪位可以把这段C#代码转为MFC代码?
- 如何提取本机所有的网页浏览历史
- Release环境下调式
- 出现Please specify the executable file对话框的问题,请问如何解决呢??
- 关于CEdit的问题
- 几个问题,100分,解决还有分加
- 问题比较呆,第一次使用 AfxBeginThread 就提示有内存泄漏!搞不懂?
- 贴子没了,再发一次!
- 小弟的毕业设计 求助
- 如何是窗口背景透明?
- CDialog::OnMouseMove(nFlags, point);//这个有与没有怎么感觉一样呢?
- av_probe_input_buffer//ffmpeg函数返回错误码Error occurred:87参数不正确是什么原因呢
VC6.0调用C#写的WebService;不安装开发包的调用方式没有试过
http://www.vckbase.com/document/viewdoc/?id=1696
VC6.0能否直接调用WebService呢?
很想知道答案
可以的。 http://www.cnblogs.com/babyblue/archive/2004/04/02/5030.aspx下面是个控制台的样例
Toolkit3.0 终于给出VC6的样例了,1.0只能看到VB和ASP的#include <stdio.h>#import "msxml4.dll"
using namespace MSXML2;#import "C:\Program Files\Common Files\MSSoap\Binaries\mssoap30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30; //你机器得安装SOAP Toolkit3.0 ,1.0时,用using namespace时报错
void Add()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30)); //HttpConnector30 失败,无法这样创建Connector,CXX0017 Error :Symbol “HttpConnector30“ not found(摇头、叹气!)
Connector->Property["EndPointURL"] = "http://MyServer/Soap3DocSamples/DocSample1/Server/DocSample1.wsdl"; //这个当然得改成您自己的拉
Connector->Connect(); // Begin the message.
//Connector->Property["SoapAction"] = "uri:AddNumbers";
Connector->Property["SoapAction"] = "http://tempuri.org/DocSample1/action/Sample1.AddNumbers";
Connector->BeginMessage(); // Create the SoapSerializer object.
Serializer.CreateInstance(__uuidof(SoapSerializer30)); // Connect the serializer object to the input stream of the connector object.
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream)); // Build the SOAP Message.
Serializer->StartEnvelope("","","");
Serializer->StartBody("");
Serializer->StartElement("AddNumbers","http://tempuri.org/DocSample1/message/","",""); //这是本地的Web Services,实际中要指定命名空间
Serializer->StartElement("NumberOne","","","");
Serializer->WriteString("5");
Serializer->EndElement();
Serializer->StartElement("NumberTwo","","","");
Serializer->WriteString("10");
Serializer->EndElement();
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope();
// Send the message to the XML Web service.
Connector->EndMessage(); // Read the response.
Reader.CreateInstance(__uuidof(SoapReader30)); // Connect the reader to the output stream of the connector object.
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), ""); // Display the result.
printf("Answer: %s\n", (const char*)Reader->RpcResult->text);
}int main()
{
CoInitialize(NULL);
Add();
CoUninitialize();
return 0;
}更改 EndPointURL 属性的值. 在URL里指定你的服务器名.OK总结一下必要的关键步骤
1.导入类型库2.需要创建一个SoapConnector3.下一步创建SoapSerializer4.下一步把消息附加到SoapConnector的输入流5.下一步读取结果.要读取服务器的回复,客户端应用需要使用SoapReader,6.SoapReader被连接到SoapConnector输出流7.用IXMLDOMElement对象可以从SoapReader里读到服务器的回复
vc6.0环境如何调用WebService呢?