|
WebService接口 XML数据处理
[WebMethod(Description = "机票用户注册")]
public string AirtripInsertUser(string identity, string request, string filter)
{
if (request != "")
{
try
{
TextReader stringReader = new StringReader(request);
DataSet ds = new DataSet();
ds.ReadXml(stringReader);
DataRow dr = ds.Tables[0].Rows[0];
if (ds.DataSetName.StartsWith("InsertUserInfo"))
{
string AirtripXML = "";
string xmlFilename = Server.MapPath("../WebXml/request_1_0.xml");
DataSet airtripDataSet = new DataSet();
airtripDataSet.ReadXml(xmlFilename);
DataRow airtrip_DR = airtripDataSet.Tables[0].Rows[0];
//return airtripDataSet.GetXml();
if (airtrip_DR.ItemArray.GetLength(0) == dr.ItemArray.GetLength(0))
{
for (int index = 0; index <= airtrip_DR.ItemArray.Length - 1; index++)
{
airtrip_DR[index] = dr[index].ToString();
}
AirtripXML = airtripDataSet.GetXml();
//airtripDataSet.WriteXml(xmlFilename);
//return "测试成功";
www_airtrip_net_cn.Service airtrip = new www_airtrip_net_cn.Service();
return airtrip.XmlSubmit(identity, AirtripXML, filter);
}
else
{
return "数据异常!";
}
}
else
{
return "开始标记与结束标记不匹配!";
}
}
catch (System.Exception e)
{
return e.Message.ToString();
}
}
else
{
return "缺少重要数据!";
}
}
[WebMethod(Description = "机票用户信息更新")]
public string AirtripUpdateUser(string identity, string request, string filter)
{
if (request != "")
{
try
{
TextReader stringReader = new StringReader(request);
DataSet ds = new DataSet();
ds.ReadXml(stringReader);
DataRow dr = ds.Tables[0].Rows[0];
if (ds.DataSetName.StartsWith("UpdateUserInfo"))
{
string AirtripXML = "";
string xmlFilename = Server.MapPath("../WebXml/request_1_0.xml");
DataSet airtripDataSet = new DataSet();
airtripDataSet.ReadXml(xmlFilename);
DataRow airtrip_DR = airtripDataSet.Tables[0].Rows[0];
//return airtripDataSet.GetXml();
if (airtrip_DR.ItemArray.GetLength(0) == dr.ItemArray.GetLength(0))
{
for (int index = 0; index <= airtrip_DR.ItemArray.Length - 1; index++)
{
airtrip_DR[index] = dr[index].ToString();
}
AirtripXML = airtripDataSet.GetXml();
AirtripXML = AirtripXML.Replace("InsertUserInfo", "UpdateUserInfo");
//airtripDataSet.WriteXml(xmlFilename);
//return "测试成功";
www_airtrip_net_cn.Service airtrip = new www_airtrip_net_cn.Service();
return airtrip.XmlSubmit(identity, AirtripXML, filter);
}
else
{
return "数据异常!";
}
}
else
{
return "开始标记与结束标记不匹配!";
}
}
catch (System.Exception e)
{
return e.Message.ToString();
}
}
else
{
return "缺少重要数据!";
}
} |
|