WCF服务Rest呼叫

WCF服务Rest呼叫,wcf,web-services,rest,soap,automapper,Wcf,Web Services,Rest,Soap,Automapper,我有一个WCF服务,可以在SOAP和REST中调用。 如果一个makesoap调用可以正常工作,但剩下的部分我就有问题了 总之,该方法返回POCO实体,但当我调用时,连接错误被取消。 如果调用另一个返回布尔值或字符串(即本机类型)的方法,则不会发生同样的情况 在我看来,我正在使用的POCO实体并不是真的(这就是我正在使用的Devart非常确定的)。 所以我所做的是,我创建了一个它的自定义映射(具有相同的属性),并使用AutoMapper进行映射 问题仍然存在:-( 这是.svc.cs publ

我有一个WCF服务,可以在SOAP和REST中调用。 如果一个makesoap调用可以正常工作,但剩下的部分我就有问题了

总之,该方法返回POCO实体,但当我调用时,连接错误被取消。 如果调用另一个返回布尔值或字符串(即本机类型)的方法,则不会发生同样的情况

在我看来,我正在使用的POCO实体并不是真的(这就是我正在使用的Devart非常确定的)。 所以我所做的是,我创建了一个它的自定义映射(具有相同的属性),并使用AutoMapper进行映射

问题仍然存在:-(

这是.svc.cs

 public List<GetLuoghiSimiliByAddressesDTO> GetLuoghiSimiliByAddress(string toponimo, string nomestrada, string civico, int idcomune)
    {
        Agile.SL.Services.IAnagraficaService srv = new Agile.SL.Services.Impl.AnagraficaService();
        List<GetLuoghiSimiliByAddressesDTO> result = new List<GetLuoghiSimiliByAddressesDTO>();
        Mapper.CreateMap<DTOGetLuoghiSimiliByAddress, GetLuoghiSimiliByAddressesDTO>();
        foreach (var dto in srv.GetLuoghiSimiliByAddress(toponimo, nomestrada, civico, idcomune).ToList<DTOGetLuoghiSimiliByAddress>())
        {
            GetLuoghiSimiliByAddressesDTO newdto = Mapper.Map<DTOGetLuoghiSimiliByAddress, GetLuoghiSimiliByAddressesDTO>(dto);
            result.Add(newdto);
        }

        return result;
    }
这是GetlooghismilibyAddressesdto

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace Merqurio.Agile.DL.Model.Entities
{
    [DataContract(IsReference = true)]
    [Serializable]
    public class GetLuoghiSimiliByAddressesDTO
    {

        private int _Id_Luogo;
        private string _Toponimo;
        private string _Nome_Strada;
        private string _Civico;


        public GetLuoghiSimiliByAddressesDTO()
        {

        }


    /// <summary>
    /// There are no comments for Id_Luogo in the schema.
    /// </summary>
        [DataMember(Order=1)]
        public int Id_Luogo
        {
            get
            {
                return this._Id_Luogo;
            }
            set
            {
                if (this._Id_Luogo != value)
                {
                    this._Id_Luogo = value;
                }
            }
        }


    /// <summary>
    /// There are no comments for Toponimo in the schema.
    /// </summary>
        [DataMember(Order=2)]
        public string Toponimo
        {
            get
            {
                return this._Toponimo;
            }
            set
            {
                if (this._Toponimo != value)
                {
                    this._Toponimo = value;
                }
            }
        }


    /// <summary>
    /// There are no comments for Nome_Strada in the schema.
    /// </summary>
        [DataMember(Order=3)]
        public string Nome_Strada
        {
            get
            {
                return this._Nome_Strada;
            }
            set
            {
                if (this._Nome_Strada != value)
                {

                    this._Nome_Strada = value;

                }
            }
        }


    /// <summary>
    /// There are no comments for Civico in the schema.
    /// </summary>
        [DataMember(Order=4)]
        public string Civico
        {
            get
            {
                return this._Civico;
            }
            set
            {
                if (this._Civico != value)
                {

                    this._Civico = value;

                }
            }
        }


    }

}
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用System.Linq;
使用System.Runtime.Serialization;
使用系统文本;
命名空间Merqurio.Agile.DL.Model.Entities
{
[DataContract(IsReference=true)]
[可序列化]
公共类GetLooghismilibyAddressedTo
{
私人国际机场;
私有字符串_Toponimo;
私有字符串_Nome_Strada;
私人字符串(u Civico),;
公共GetLoughismilibyAddressedTo()
{
}
/// 
///架构中没有Id_Luogo的注释。
/// 
[数据成员(顺序=1)]
公共国际身份证
{
得到
{
把这个还给我;
}
设置
{
if(this.\u Id\u Luogo!=值)
{
这个。_Id_Luogo=值;
}
}
}
/// 
///架构中没有Toponimo的注释。
/// 
[数据成员(顺序=2)]
公共字符串拓扑
{
得到
{
把这个还给我;
}
设置
{
if(this.\u Toponimo!=值)
{
这是.\u Toponimo=值;
}
}
}
/// 
///架构中没有对Nome_Strada的注释。
/// 
[数据成员(顺序=3)]
公共字符串Nome_Strada
{
得到
{
把这个还给我;
}
设置
{
如果(该值)
{
这。_Nome_Strada=值;
}
}
}
/// 
///架构中没有对Civico的注释。
/// 
[数据成员(顺序=4)]
公共字符串公民
{
得到
{
把这个还给我;
}
设置
{
如果(此._Civico!=值)
{
这个。_Civico=值;
}
}
}
}
}
请帮帮我!

您不能在数据合同上使用“IsReference=true”

从MSDN:

使用IsReference属性指示DataContractSerializer 插入保留对象引用信息的XML构造

您返回的是JSON,而不是XML


无论如何,您在这里不需要它,我看不到任何循环依赖关系。

当您进行REST调用时,返回的错误代码是什么。还要尝试在您的服务上启用跟踪,以查看请求通过REST失败的原因。要启用跟踪,请遵循以下步骤


还可以尝试使用fiddler检查对您的服务提出的请求。

您可以将GetLoughismilibyAddresssDTO显示为代码吗?是的,我已经完成了!您能帮助我吗?
    public bool IsUserAlreadyRegistered(string email)
    {
        Agile.SL.Services.IAnagraficaService srv = new Agile.SL.Services.Impl.AnagraficaService();
        return srv.CheckEmailExistance(email);
    }            

[OperationContract]
[WebGet(UriTemplate = "IsUserAlreadyRegistered?Email={email}",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json)]
bool IsUserAlreadyRegistered(string email);
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace Merqurio.Agile.DL.Model.Entities
{
    [DataContract(IsReference = true)]
    [Serializable]
    public class GetLuoghiSimiliByAddressesDTO
    {

        private int _Id_Luogo;
        private string _Toponimo;
        private string _Nome_Strada;
        private string _Civico;


        public GetLuoghiSimiliByAddressesDTO()
        {

        }


    /// <summary>
    /// There are no comments for Id_Luogo in the schema.
    /// </summary>
        [DataMember(Order=1)]
        public int Id_Luogo
        {
            get
            {
                return this._Id_Luogo;
            }
            set
            {
                if (this._Id_Luogo != value)
                {
                    this._Id_Luogo = value;
                }
            }
        }


    /// <summary>
    /// There are no comments for Toponimo in the schema.
    /// </summary>
        [DataMember(Order=2)]
        public string Toponimo
        {
            get
            {
                return this._Toponimo;
            }
            set
            {
                if (this._Toponimo != value)
                {
                    this._Toponimo = value;
                }
            }
        }


    /// <summary>
    /// There are no comments for Nome_Strada in the schema.
    /// </summary>
        [DataMember(Order=3)]
        public string Nome_Strada
        {
            get
            {
                return this._Nome_Strada;
            }
            set
            {
                if (this._Nome_Strada != value)
                {

                    this._Nome_Strada = value;

                }
            }
        }


    /// <summary>
    /// There are no comments for Civico in the schema.
    /// </summary>
        [DataMember(Order=4)]
        public string Civico
        {
            get
            {
                return this._Civico;
            }
            set
            {
                if (this._Civico != value)
                {

                    this._Civico = value;

                }
            }
        }


    }

}