【发布时间】:2011-01-05 18:04:32
【问题描述】:
我的 WCF JSONP Web 服务遇到了一个“有趣的”错误。它是我唯一拥有的,它只公开一种方法。如果我通过网络浏览器 internally 访问我的服务,它会弹出一条消息,实际上 MEX 未启用 (true)。如果我从我们的网络外部点击它(就像你会,除非你在我公司的一台机器上)它只是坐在那里,最后超时。网址是:http://demo.rivworks.com/services/Negotiate.svc。关于可能导致此行为的任何想法?
这是 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.INegotiateService" />
</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>
</configuration>
代码如下:
namespace RivWorks.Web.Service
{
//----------------------------------------------------------------------------------------------------------//
// Data class //
//----------------------------------------------------------------------------------------------------------//
[DataContract(Name = "NegotiateSetup", Namespace = "http://rivworks.com/DataContracts/2009/01/15")]
public class NegotiateSetup : INegotiationInitialize
{
#region Declarations
...
#endregion
#region INegotiationInitialize Members
...
#endregion
}
//----------------------------------------------------------------------------------------------------------//
// Service Implementation //
//----------------------------------------------------------------------------------------------------------//
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class NegotiateService : INegotiateService
{
public NegotiateService() { }
public INegotiationInitialize GetSetup(string method, string jsonInput)
{
...
return resultSet;
}
}
}
我在这里做了几件事:
- 为什么我不能从我的本地网络之外点击它?
- 如何让 MEX 正常工作
注意:我正在使用此处找到的 JSONP 类:http://msdn.microsoft.com/en-us/library/cc716898.aspx
【问题讨论】:
-
您是否排除了防火墙规则?例如,如果你在那台机器上放置一个静态页面,你能从防火墙外访问它吗?
-
答案似乎是否定的。我应该能够点击demo.rivworks.com/login.aspx,但我不能,而且它也会超时。这是一个 RackSpace 服务器,所以星期一我将与他们一起输入故障单。
-
嗨,Keith,这听起来像是防火墙问题。鉴于您根本无法达到终点,这表明它与 WCF 本身无关。另一个简单的测试是删除一个简单的 HelloWorld 文本文件或一个简单的 html 文件,看看你是否可以点击它。
标签: wcf accessibility jsonp mex