gpt4 book ai didi

c# - 净::ERR_CONNECTION_RESET REST WCF

转载 作者:太空宇宙 更新时间:2023-11-03 13:12:13 28 4
gpt4 key购买 nike

你好所以我做了 rest wcf 并尝试完成一些对象调用并在它返回对象列表后我得到消息:

GET http://localhost/ESService/ESService.svc/GetExecutiveSummariesByBuyer?buyerId=1 net::ERR_CONNECTION_RESET

我查过谷歌,有一些信息可以将其添加到 webconfig 中:

 <behavior name="restfulBehavior">
<dataContractSerializer maxItemsInObjectGraph="1234567" />
<webHttp />
</behavior>

但仍然没有运气来自服务器的相同答案:这是我的数据契约(Contract)

using System;
using System.Runtime.Serialization;

namespace ESContracts
{
[DataContract]
public class ExecutiveSummaries
{
[DataMember] public int BuyerID;
[DataMember] public DateTime CheckOutDate;
[DataMember] public int CheckOutPerson;
[DataMember] public DateTime CreateDate;
[DataMember] public int CreatedBy;
[DataMember] public int CustomerID;
[DataMember] public bool Deleted;
[DataMember] public int DeletedBy;
[DataMember] public DateTime DeletedDate;
[DataMember] public int ESStatusID;
[DataMember] public int ID;
[DataMember] public bool IsDecisionGroup;
[DataMember] public bool IsWritingStyleFormal;
[DataMember] public int ModifiedBy;
[DataMember] public DateTime ModifiedDate;
[DataMember] public string OpportunityTitle;
[DataMember] public string Step2_Achievement;
[DataMember] public int Step2_ComplianceID;
[DataMember] public string Step2_Intention;
[DataMember] public string Step2_SolutionAttribute;
}
}

--编辑

我忘了添加接口(interface)定义:)

    [ServiceContract]
public interface IESService{....


[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "GetExecutiveSummariesByBuyer?buyerId={BuyerId}")]
List<ExecutiveSummaries> GetExecutiveSummariesByBuyer(string BuyerId);

当我将日期时间更改为字符串时,有什么想法吗?

最佳答案

这是执行此操作的 Javascript 代码示例 :)

String.prototype.FromWCFToJSONDate = function () {
return new Date(parseInt(this.match(/\/Date\(([0-9]+)(?:.*)\)\//)[1]));
};
Date.prototype.JSONDateTOWCF = function () {
var dt = this;
var timestamp = dt.getTime();
var date = '/Date(' + timestamp + '+0000)/'; // returns local time
return date;
};

关于c# - 净::ERR_CONNECTION_RESET REST WCF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28026263/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com