问题描述
Web服务问题...
我正在构建一个Web服务,以将xml数据来回传递给android平板电脑.我将控制此服务的两端,因此第三方将无法使用它.该Web服务是用C#编写的.我的问题是...参数之一将是Android平板电脑用户的userId,但我还需要传递将要写入服务器上的master数据库的结构数据,并使用数据.我正在考虑只接受一个xml字符串作为第二个参数,该参数包含我需要的结构中的数据.请告知这是否是一个不错的选择,如果可以,我可以在确定如何在Web服务的C#Web方法中编写代码方面提供一些帮助.任何帮助将不胜感激...
Web Service Troubles...
I''m building a web service to pass xml data back and forth to android tablets. I will control both ends of this service, so it will not be available to third parties. The web service is being written in C#. My question is this... One of the parameters will need to be the userId of the Android tablet user, but I also need to pass structure data that I will be writing to a master database on a server and do some other processes with the data. I was thinking of just accepting an xml string as the second parameter that contains the data in the struct that I need. Please advise if this is a good option and if it is, I could use a little help on figuring out how to code this up in the C# web method in the web service. Any help would be appreciated...
推荐答案
public class androidData
{
public String userID{get;set;}
public class InnerStruct
{
public int InnerID{get;set;}
}
}
之后,可以使用以下操作编写服务器代码以更新数据:
Later, server code can be written to update the data using the below operation:
[WebMethod]
public bool UpdateOperation(DataSet androidClient)
{
if (!this.Open())
return true;
SqlDataAdapter oDSCommand = new SqlDataAdapter("sqlqurey..",this.oConn);
SqlCommandBuilder oCmdBuilder = new SqlCommandBuilder(oDSCommand);
int lnRows = 0;
try
{
lnRows = oDSCommand.Update(androidClient,"DBTable");
}
catch(Exception e)
{
return false;
}
if ( lnRows < 1 )
return false;
return true;
}
这篇关于在.Net Web服务中接收XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!