WCF - (504)服务器未返回此请求的响应
我有一个JSONP WCF端点,我试图找出为什么我得到504错误。
HTTP / 1.1 504 Fiddler - 接收失败
内容类型:text / html
连接:关闭
时间戳:11:45:45:9580
ReadResponse()失败:服务器未返回此请求的响应。
我可以在我的Endpoint内部的任何地方设置断点,逐步执行代码,看到它成功收集响应所需的数据,点击最后一行代码,然后一旦我退出WCF调用,我就得到504错误。这是在上周工作!
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceContract(Name = "NegotiateService", Namespace = "http://rivworks.com/Services/2009/01/15")]
public class NegotiateService //: svcContracts.INegotiateService
{
public NegotiateService() { }
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public dataObjects.NegotiateSetup GetSetup(string method, string jsonInput)
{
dataObjects.NegotiateSetup resultSet = new dataObjects.NegotiateSetup();
using (RivFeedsEntities1 _dbFeed = new FeedStoreReadOnly(AppSettings.FeedAutosEntities_connString, "", "").ReadOnlyEntities())
{
using (RivEntities _dbRiv = new RivWorksStore(AppSettings.RivWorkEntities_connString, "", "").NegotiationEntities())
{
// Deserialize the input and get all the data we need...
Newtonsoft.Json.Linq.JObject o = Newtonsoft.Json.Linq.JObject.Parse(jsonInput);
string urlRef = String.Format("{0}", o["ref"]).Replace(""", "");
string clientDate = String.Format("{0}", o["dt"]).Replace(""", "");
string ProductID = String.Format("({0})", o["productId"]).Replace(""", "");
string SKU = String.Format("{0}", o["sku"]).Replace(""", "");
string env = String.Format("{0}", o["env"]).Replace(""", "");
IList<Product> efProductList = null;
Product workingProduct = null;
vwCompanyDetails workingCompany = null;
bool foundItem = false;
if (!String.IsNullOrEmpty(SKU))
efProductList = _dbRiv.Product.Include("Company").Where(a => a.SKU == SKU).ToList();
else if (!String.IsNullOrEmpty(ProductID))
efProductList = _dbRiv.Product.Include("Company").Where(a => a.ProductId == new Guid(ProductID)).ToList();
foreach (Product product in efProductList)
{
if (String.IsNullOrEmpty(product.URLDomain))
{
var efCompany = _dbRiv.vwCompanyDetails
.Where(a => a.defaultURLDomain != null && a.CompanyId == product.Company.CompanyId)
.FirstOrDefault();
if (efCompany != null && urlRef.Contains(efCompany.defaultURLDomain))
{
foundItem = true;
workingProduct = product;
workingCompany = efCompany;
}
}
else
{
if (urlRef.Contains(product.URLDomain))
{
foundItem = true;
workingProduct = product;
workingCompany = _dbRiv.vwCompanyDetails
.Where(a => a.CompanyId == product.Company.CompanyId)
.FirstOrDefault();
}
}
}
if (foundItem)
{
try
{
// Update the resultSet...
if (workingProduct != null && workingCompany != null)
{
string rootUrl = String.Empty;
try
{
rootUrl = AppSettings.RootUrl;
}
catch
{
rootUrl = env + @"/";
}
resultSet.button = workingProduct.ButtonConfig;
resultSet.swfSource = String.Format(@"{0}flash/negotiationPlayer.swf", rootUrl);
resultSet.gateway = rootUrl;
resultSet.productID = workingProduct.ProductId.ToString();
resultSet.buttonPositionCSS = workingProduct.buttonPositionCSS;
}
}
catch (Exception ex)
{
log.WriteLine(" ERROR: ", ex.Message);
log.WriteLine("STACK TRACE: ", ex.StackTrace);
}
}
}
}
return resultSet;
}
}
我的web.config:
<!-- WCF configuration -->
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="JsonpServiceBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="RivWorks.Web.Service.NegotiateService">
<endpoint address=""
binding="customBinding"
bindingConfiguration="jsonpBinding"
behaviorConfiguration="JsonpServiceBehavior"
contract="RivWorks.Web.Service.NegotiateService" />
</service>
</services>
<extensions>
<bindingElementExtensions>
<add name="jsonpMessageEncoding" type="RivWorks.Web.Service.JSONPBindingExtension, RivWorks.Web.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bindingElementExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="jsonpBinding" >
<jsonpMessageEncoding />
<httpTransport manualAddressing="true"/>
</binding>
</customBinding>
</bindings>
</system.serviceModel>
正如我所说,代码一直运行,所以我试图找出它为什么不发送响应。
没有找到相关结果
已邀请:
7 个回复
惜堡沁戚
眠缝
镀建啼
刷骸码
有助于解决递归循环问题,但由于DataContractJsonSerializer不支持引用,因此我必须将格式切换为XML。 (P.S. - 使用WEB API,默认的JSON序列化程序将是JSON.NET,它将处理引用而没有问题)。 提示:正如其他人所建议的那样,WCF Trace Logging是您解决504错误的朋友。
磐去裸猜饲
和wcf似乎不明白如何编码对象。我返回的对象完全没有字符串和整数。我不得不改变对此的响应以使其工作:
缮淳彼誊
属性如何在责任类中
,如何引起Fiddler的504响应。
字符串属性没有问题。
断跑胺弄萎