您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> .NET >> soap协议 soap 访问 web service ,无法传递参数。

soap协议 soap 访问 web service ,无法传递参数。

来源:网络整理     时间:2016/8/17 21:53:05     关键词:soap协议

关于网友提出的“soap协议 soap 访问 web service ,无法传递参数。”问题疑问,本网通过在网上对“soap协议 soap 访问 web service ,无法传递参数。”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题:soap协议 soap 访问 web service ,无法传递参数。
描述:

asp.net web服务的代码如下:
[WebMethod]
public string AddCard(int guid, string key) 
{
int m = guid;
return "OK!";
}
soap30 客户端的代码如下:
   ISoapSerializerPtr Serializer;
   ISoapReaderPtr Reader;
   ISoapConnectorPtr Connector;
   Connector.CreateInstance(__uuidof(HttpConnector30));
   Connector.CreateInstance(__uuidof(HttpConnector30));
   Connector->Property["EndPointURL"] = "http://172.25.16.65/vdo/Backend/Service1.asmx";
   Connector->Connect();
   // begin message
   Connector->Property["SoapAction"] = "http://tempuri.org/AddCard";
   Connector->BeginMessage();
   // create serializer
   Serializer.CreateInstance(__uuidof(SoapSerializer30));
   // interface serializer
   Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
   // make soap packet
   Serializer->StartEnvelope("","","");
   Serializer->StartBody("");
   Serializer->StartElement("AddCard","http://tempuri.org","NONE","SOAP");
   Serializer->StartElement("guid","http://tempuri.org","NONE","SOAP");
   Serializer->WriteString("55");
   Serializer->EndElement();
   Serializer->StartElement("key","http://tempuri.org","NONE","SOAP");
   Serializer->WriteString("10254");
   Serializer->EndElement();
   Serializer->EndElement();
   Serializer->EndBody();
   Serializer->EndEnvelope();
   // send message
   Connector->EndMessage();
   // recv response message
   Reader.CreateInstance(__uuidof(SoapReader30));
   // connect output stream
   if(Connector->OutputStream)
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
   // printf result
   if(Reader)
   if(Reader->RpcResult)
   if(strlen((const char *)Reader->RpcResult->text))
   {
   CString str = Reader->RpcResult->text;
   //str.Format("%s",(const char *)Reader->RPCResult->text);
   AfxMessageBox(str);
   }
执行客户端时,可以调用服务端的AddCard方法,但是传近来的参数int guid, string key始终煤烟值,guid == 0 key == null,
搞不懂哪里出了问题。请各位指教!谢谢!


以上介绍了“soap协议 soap 访问 web service ,无法传递参数。”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3351377.html

soap协议相关图片

soap协议相关文章