2

我制作了一个应该返回实体“UserProfile”的网络服务。大多数操作都会返回预期结果,但是当我直接返回生成的类时会得到空响应。

服务:

List<UserProfile> IMusicOwnerService.getProfiles()
    {
        return context.UserProfileSet.ToList();
    }

要求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:getProfiles/>
   </soapenv:Body>
</soapenv:Envelope>

我修改了 Model.tt 文件(根据这个答案)然后生成了这个类:

    using System;
    using System.Collections.Generic;
    using System.Runtime.Serialization;  //Template modification test
    [DataContract]//Template modification test
    public partial class UserProfile
    {

        public UserProfile()
        {
            this.LoginSession = new HashSet<LoginSession>();
            this.Playlist = new HashSet<Playlist>();
            this.Friends = new HashSet<UserProfile>();
            this.Song = new HashSet<Song>();
        }

        [DataMember]//Template modification test
        public int Id { get; set; }
        [DataMember]//Template modification test
        public string UserName { get; set; }
        [DataMember]//Template modification test
        public string Email { get; set; }
        [DataMember]//Template modification test
        public string Password { get; set; }
        [DataMember]//Template modification test
        public string Salt { get; set; }

}

发送请求时没有响应。

http://imgur.com/AvtTmNE (没有足够的声誉来张贴图片)

4

0 回答 0