Web Service调用的时候参数全部变为0了?

Eastunfail 2005-07-09 11:56:48
就这样的一个C#函数:
[WebMethod(true)]
public int Add(int N1,int N2)
{
return N1+N2;
}
调用Web Service用VC写的:
ISoapConnectorPtr Connector;
Connector.CreateInstance(__uuidof(HttpConnector));
Connector->Property["EndPointURL"]="http://localhost/dotNET/index.asmx";
Connector->Connect();

ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;

Connector->Property["SoapAction"]=("http://tempuri.org/"+m_Action).c_str();
Connector->BeginMessage();
// 创建SoapSerializer对象
Serializer.CreateInstance(__uuidof(SoapSerializer));
// 将serializer连接到connector的输入字符串
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
//Create SOAP Message
Serializer->startEnvelope("soap",_bstr_t(),"utf-8");
Serializer->startBody(_bstr_t());
Serializer->startElement(m_Action.c_str(),"http://tempuri.org/",_bstr_t(),"m");
Serializer->startElement("N1","",_bstr_t(),"");
Serializer->writeString("2");
Serializer->endElement();
Serializer->startElement("N2","",_bstr_t(),"");
Serializer->writeString("3");
Serializer->endElement();
Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();
//Send message to web service
Connector->EndMessage();
//Read response
Reader.CreateInstance(__uuidof(SoapReader));
// 将reader联接到connector的输出字符串
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
return (char*)Reader->RPCResult->xml;


传给Web Service的数据为:
POST /dotNET/index.asmx HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 228
Content-Type: text/xml
Cookie: alibabaName=alibabas; Ajiangalibaba%5Fstat1=Ajstat2=1; AjStatalibaba%5Fstat1=UserPages=1&AjstatPages=1; steel35%2DKill=kill=0
Host: localhost
User-Agent: SOAP Sdk
SOAPAction: "http://tempuri.org/Add"
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<m:Add xmlns:m="http://tempuri.org/">
<N1>2</N1>
<N2>3</N2>
</m:Add>
</soap:Body>
</soap:Envelope>


Add能够正确调用,但是传给N1和N2的值确是0?修改为字符串类型的话,N1和N2变成null了?

哪里错了呢?
...全文
466 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jinjazz 2005-08-29
UP.... ^^!
  • 打赏
  • 举报
回复
Eastunfail 2005-07-09
怎么没有人看啊?

m_Action 这里是 Add
  • 打赏
  • 举报
回复
Eastunfail 2005-07-09
顶上去

原来问题在Serializer,生成的方法调用的节点前面总是有前缀,如何去掉前缀?或者让Web Service接受这个前缀?
  • 打赏
  • 举报
回复
CDSoftwareWj 2005-07-09
我是不会,纯UP.... ^^!
  • 打赏
  • 举报
回复
syeerzy 2005-07-09
VC调用WebService没试过....好像不容易看出来哪里错.

不如你对这个地方逐行运行然后一直监视这2个的流向,应该能看出问题的点
  • 打赏
  • 举报
回复
相关推荐
发帖
C#
加入

10.7w+

社区成员

.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
申请成为版主
帖子事件
创建了帖子
2005-07-09 11:56
社区公告

让您成为最强悍的C#开发者