请检查下面的代码
[ServiceContract]
public interface IService1
{
[OperationContract]
System.Xml.XmlDocumentGetData(int userId);
}
public MySqlConnectionStringBuilder Sbu = new MySqlConnectionStringBuilder();
public static DataTable dt = new DataTable();
public static DataSet myDataSet = new DataSet();
public XmlDocument GetData(int userId)
{
MySqlConnection con = new MySqlConnection()
String Query = "select * from user_master where UserID = "+userId;
MySqlDataAdapter adapter =new MySqlDataAdapter();
adapter.SelectCommand =new MySqlCommand(Query,con);
adapter.Fill(dt);
myDataSet.Tables.Add(dt);
string xmlStr = "";
XmlDocument xmlDoc = new XmlDocument();
xmlStr = myDataSet.GetXml();
xmlDoc.LoadXml(xmlStr);
return xmlDoc;
}
发生异常:
接收到localhost的HTTP响应时发生错误。这可能是由于服务端点绑定不使用HTTP协议。这也可能是由于服务器中止HTTP请求上下文(可能是由于服务关闭)。有关详细信息,请参阅服务器日志。
通过客户消费
ServiceProxy.Service1Client client = new ServiceProxy.Service1Client();
client.GetData(Convert.ToInt32(txtUserID.Text));