高分求:C++调用C#写的WebService函数,参数无法传递 解决的方法

icy_heart 2008-09-29 05:15:24
C++源代码如下

ISoapConnectorPtr Connector;
Connector.CreateInstance(__uuidof(HttpConnector));
Connector->Property["EndPointURL"]= "http://localhost:1070/Main.asmx";
Connector->Connect();
Connector->Property["SoapAction"] = "http://tempuri.org/GetSize";

Connector->BeginMessage();
ISoapSerializerPtr Serializer;
Serializer.CreateInstance(__uuidof(SoapSerializer));
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
Serializer->startEnvelope("SOAP","","");

Serializer->startBody(L"NONE");
Serializer->startElement("GetString","http://tempuri.org/","NONE","");

Serializer->startElement("str","","NONE","");
Serializer->writeString("abc");
Serializer->endElement();

Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();
Connector->EndMessage();


WebService函数C#源代码如下
 public string GetString(string str)
{

return str;
}


代码如上,能调用到WebService的函数,却无法传递参数,我想这应该是2种语言参数类型的问题,我想问一下,有没有办法解决这个问题.
高分酬谢

...全文
167 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
blackcat242 2008-09-30
  • 打赏
  • 举报
回复
不会,帮顶
icy_heart 2008-09-29
  • 打赏
  • 举报
回复
哎.终于知道原因了..

namespace WebService
{
/// <summary>
/// Service1 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
//[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
// [System.Web.Script.Services.ScriptService]
[System.Web.Services.Protocols.SoapRpcService]

public class Service1 : System.Web.Services.WebService
{

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string GetString(string strName)
{
return strName;
}
}
}
这样定义
关键就在[System.Web.Services.Protocols.SoapRpcService]这一句
cattycat 2008-09-29
  • 打赏
  • 举报
回复
Serializer->startElement("GetString","http://tempuri.org/","NONE","");
这里不用传递参数么,没用过C++的,Java的WebService不是这样的。你再查一下startElement怎么用的。
友情支持了。
icy_heart 2008-09-29
  • 打赏
  • 举报
回复
csdn没人了么,自己顶上去

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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