我写了一个webservice,怎样返回一个wsdl文件让客户端调用

解决方案 »

  1.   

    直接用浏览器访问,就能下载wsdl...专业点就用svcutil工具下载,svcutil也可以验证主机甚至直接生成客户端代理代码...
      

  2.   

    问题是访问的时候没有wsdl文件啊
      

  3.   


    在浏览器中访问http://*****/***.svc?wsdl
      

  4.   


    .net webservice 的wsdl不是一个physical的文件,而是根据实现动态生成的。
      

  5.   

    谢谢你的回答,由于对webservice不明白,问题描述得不清楚
    按照你的建议,访问http://*****/***.svc?wsdl后,确实能返回一个wsdl
    现在的问题是怎样控制wsdl中返回的值我的webserice方法:
    [WebMethod]
     public UserInfo GetUserByAccount(string accountID)
     {
         UserInfo user = new UserInfo();
         return user;
     }
    ////
    UserInfo类:
     public class UserInfo
        {
                string SerialID;
                string FullName;
                string DeptID;
                string DeptName;
                public bool GetUser(string accountID)
                {
                    string sql = "select FullName,DeptID,DeptName from ACCOUNT_TITLE_VIEW where AccountID='" + accountID + "'";
                    DataTable dt = GetDataTable(sql);
                    FullName = dt.Rows[0]["FullName"].ToString();
                    DeptID = dt.Rows[0]["DeptID"].ToString();
                    DeptName = dt.Rows[0]["DeptName"].ToString();
                    string TheYear = DateTime.Now.Year.ToString();
                    string TheMonth = DateTime.Now.Month.ToString();
                    string TheDay = DateTime.Now.Day.ToString();
                    string TheHour = DateTime.Now.Hour.ToString();
                    string TheMinute = DateTime.Now.Minute.ToString();
                    string TheSecond = DateTime.Now.Second.ToString();
                    SerialID = TheYear + TheMonth + TheDay + TheHour + TheMinute + TheSecond + accountID;
                    return true;
                }            public DataTable GetDataTable(string sql)
                {
                    SqlConnection sqlCon = new SqlConnection(ConfigurationSettings.AppSettings["sql"].ToString());
                    sqlCon.Open();
                    DataSet ds = new DataSet();
                    SqlCommand cmd = new SqlCommand(sql, sqlCon);
                    try
                    {
                        cmd.CommandTimeout = 20;
                        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                        adapter.Fill(ds, "tempTable");
                    }
                    catch (Exception e)
                    {
                        ds = null;
                    }
                    finally
                    {
                        cmd.Dispose();
                        sqlCon.Dispose();
                        sqlCon.Close();                }
                    return ds.Tables[0];
                } 
        }wsdl返回的值:
    <?xml version="1.0" encoding="utf-8" ?> 
      <UserInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/" /> 我想要的wsdl结果是:
    <?xml version="1.0" encoding="utf-8" ?> 
      <UserInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/" /> 
    <SerialID>20113810492690001</SerialID> 
      <FullName>傅文彪</FullName> 
      <DeptID>CEO</DeptID> 
      <DeptName>CEO</DeptName> 
    </UserInfo>
      

  6.   

    你的UserInfo不是实体类...字段不会被序列化,更何况你还都是私有字段...也就是说你的UserInfo本来就没有元数据,wsdl当然是空的...把SerialID神马的都改成属性...另外,方法是不会被传递的,soap传递的对象是xml,只有数据能被传递...
      

  7.   

    你要的那个叫soap message。wsdl是描述web service的。
      

  8.   

    对...wsdl实际上是个xsd,是xml的结构,是没有“值”的...你“想要的wsdl结果”是不可能的...
      

  9.   

    你想要的结果是用HttpRequest方式返回的结果,比如:http://localhost:4132/Service1.asmx/GetUserByAccount