我创建了一个Web服务方法,该方法将Dataset
作为参数,并且必须以XMLDocument
的形式发送参数,而不是使用以下代码的任何其他方式:
public static bool UpdateUnitMst(string isLive, string EmpId, string EmpNameFull, DataSet dst, string where)
{
XmlDocument soapEnvelopeXml = new XmlDocument();
string xmlToLoad = @"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope
xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<soap:Body>
<UpdateUnitMst xmlns=""http://abc/services/"">"
+ "<isLive>" + isLive + "</isLive>"
+ "<EmpId>" + EmpId + "</EmpId>"
+ "<EmpNameFull>" + EmpNameFull + "</EmpNameFull>"
+ "<dst>" + dst + "</dst>"
+ "<where>" + where + "</where>"
+ "</UpdateUnitMst>"
+ "</soap:Body>"
+ "</soap:Envelope>";
soapEnvelopeXml.LoadXml(xmlToLoad);
try
{
HttpWebRequest request = GetWebRequest();
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
string xmlString = rd.ReadToEnd();
XmlDocument soapResult = new XmlDocument();
soapResult.LoadXml(xmlString);
string result = soapResult.GetElementsByTagName("UpdateUnitMstResult")[0].InnerText;
if (result != "success")
return false;
}
}
}
catch (Exception) { }
return true;
}
请帮助我,我被困了几天。 提前谢谢。