web service使用问题

stevenjin 2019-04-17 10:33:41
web service我只知道看教程发布一个web service服务(如:http://localhost/AddService.asmx),
然后另开一个项目去引入web服务这样子。
1.不知道商业化的用法是怎样的呀?

2.最近看到项目有这样用,这个(http://90.180.156.11:5600/meswebservice/RunService)是个已经发布的服务,
方法只是去调用这个服务还是怎样?
求指教,致谢。

 public static string[] RunService(string site, string data, string url = @"http://90.180.156.11:5600/meswebservice/ExecutingService", string userName = "mesuser", string password = "7993")
{
string[] arrMsg = new string[3];
try
{
HttpWebRequest request = CreateWebRequest(url, userName, password);
XmlDocument soapEnvelopeXml = new XmlDocument();

string str1 = string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:base=""http://base.ws.sapdev.com/"">
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<base:execute>
<pRequest>
<site>{0}</site>
<data>{1}</data>
</pRequest>
</base:execute>
</soapenv:Body>
</soapenv:Envelope>", site, data);
soapEnvelopeXml.LoadXml(str1);

using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}

using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
string resMsg = rd.ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(resMsg);
XmlNode root = xmlDoc.SelectSingleNode("//status");
arrMsg[0] = Convert.ToInt32(Convert.ToBoolean(root.InnerText)).ToString();
root = xmlDoc.SelectSingleNode("//message");
arrMsg[1] = root.InnerText;

root = xmlDoc.SelectSingleNode("//returnList");
if (root != null)
arrMsg[2] = root.InnerText;
}
}

}
catch (Exception ex)
{
arrMsg[0] = "0";
arrMsg[1] = ex.Message;
}
return arrMsg;
}
}
...全文
111 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
stherix 2019-04-18
  • 打赏
  • 举报
回复
要看这个web service是什么技术生成的,支持哪些访问方法 一般用vs添加服务引用生成代理类访问时最方便的
  • 打赏
  • 举报
回复
webservice用http请求或者引用服务都行,
我个人是用http请求的,
引用服务每次更新接口后都要重新生成引用,我嫌麻烦

12,162

社区成员

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

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