VC6.0下调用C#编写的WebService存在的问题?

userxk 2005-01-09 12:59:41
今用C#编写了一个最简单的WebService方法调用:
[WebMethod]
public string HelloWorld(string name)
{
return name;
}

现在VC6.0下采用SOAP Toolkit 3.0调用此接口:
void CSoapDlg::GetReturnVal()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service.
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property["EndPointURL"]= "http://192.168.1.8/MyService/ServiceList.asmx";
Connector->Connect();

// Begin the message.
Connector->Property[_T("SoapAction")] = _T("http://192.168.1.8/MyService/ServiceList.asmx/HelloWorld");
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(_T("HelloWorld"),_T(""),_T(""));
Serializer->StartBody("");
Serializer->StartElement(_T("HelloWorld"),_T("http://192.168.1.8/MyService/ServiceList.asmx/"),
_T(""),_T(""));
Serializer->StartElement("name","","","");
Serializer->WriteString("张");
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), "");

MessageBox((const char*)Reader->RpcResult->text);
}
可就是无法得到WebService的返回值,MessageBox里显示的是“soap:Client”的提示信息。


...全文
281 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
haoco 2005-02-03
  • 打赏
  • 举报
回复
up
userxk 2005-01-25
  • 打赏
  • 举报
回复
赶快“友情UP”呀!!!
huangsuipeng 2005-01-19
  • 打赏
  • 举报
回复
JF
心情解码 2005-01-19
  • 打赏
  • 举报
回复
up



-- :0
userxk 2005-01-18
  • 打赏
  • 举报
回复
up也可能有分。
Tomgus 2005-01-15
  • 打赏
  • 举报
回复
那就恭喜楼主
再接点分:)
robin0925 2005-01-15
  • 打赏
  • 举报
回复
恭喜恭喜
楼主真牛。。。。。
userxk 2005-01-12
  • 打赏
  • 举报
回复
哈哈!自己搞定了。
返回值和返回XML解析文本都一起解决了。
liulxmooo 2005-01-11
  • 打赏
  • 举报
回复
up
LoveCherry 2005-01-09
  • 打赏
  • 举报
回复
up给分吗
userxk 2005-01-09
  • 打赏
  • 举报
回复
CSDN的各位MVP们能不能帮忙看看?

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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