12,162
社区成员
发帖
与我相关
我的任务
分享
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;
}
}