我正在運行WCF JSONP Web服務時發生「有趣」的錯誤。這是我擁有的唯一一個,它只公開一種方法。如果我通過網絡瀏覽器內部打開我的服務,它會彈出一條消息,實際上MEX未啓用(true)。如果我從網絡外部擊中它(就像你會在我公司的機器上一樣),它就會坐下來,最後超時。網址是:http://demo.rivworks.com/services/Negotiate.svc。任何想法可能會導致這種行爲?C#WCF在企業防火牆內部工作,但不在外部
這裏是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;
}
}
}
我幾件事情後,在這裏:
- 爲什麼我NOT從我的本地網絡之外擊中它?
- 我怎樣才能得到MEX正常工作
注:我用在這裏找到了JSONP類:http://msdn.microsoft.com/en-us/library/cc716898.aspx
您排除了防火牆規則嗎?例如,如果您在該機器上放置靜態頁面,您是否可以從防火牆外部訪問它? – itowlson 2010-01-16 00:55:01
答案似乎不是。我**應該**能夠擊中http://demo.rivworks.com/login.aspx,但我不能和它超時。這是一臺RackSpace服務器,所以週一我會和他們一起輸入一張故障單。 – 2010-01-16 03:02:51
嗨基思,它聞起來像一個防火牆問題。鑑於你無法完全達到終點,它與WCF本身無關。另一個簡單的測試是放棄一個簡單的HelloWorld文本文件或一個簡單的html文件,看看是否可以實現。 – bahree 2010-01-16 10:52:44