2010-01-16 28 views
1

我正在運行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; 
     } 
    } 
} 

我幾件事情後,在這裏:

  1. 爲什麼我NOT從我的本地網絡之外擊中它?
  2. 我怎樣才能得到MEX正常工作

注:我用在這裏找到了JSONP類:http://msdn.microsoft.com/en-us/library/cc716898.aspx

+0

您排除了防火牆規則嗎?例如,如果您在該機器上放置靜態頁面,您是否可以從防火牆外部訪問它? – itowlson 2010-01-16 00:55:01

+0

答案似乎不是。我**應該**能夠擊中http://demo.rivworks.com/login.aspx,但我不能和它超時。這是一臺RackSpace服務器,所以週一我會和他們一起輸入一張故障單。 – 2010-01-16 03:02:51

+0

嗨基思,它聞起來像一個防火牆問題。鑑於你無法完全達到終點,它與WCF本身無關。另一個簡單的測試是放棄一個簡單的HelloWorld文本文件或一個簡單的html文件,看看是否可以實現。 – bahree 2010-01-16 10:52:44

回答

0

爲了使您的MEX,添加此您service標籤中:

<endpoint address="mex" 
      binding="mexHttpBinding" 
      contract="IMetadataExchange" /> 

在您的behaviors標籤內添加:

<serviceBehaviors> 
    <behavior name="JsonpServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true"/> 
    </behavior> 
    </serviceBehaviors> 

關於爲什麼該服務無法從外部訪問,這是防火牆問題嗎?

+0

我們發現我們的託管公司已經更改了這個特定站點的IP地址,「因爲SSL衝突」 - 儘管它現在運行穩定了近一年。我們有一箇中級證書失敗,不得不重新安裝我們的外卡證書。沒有運行用於將主機標頭映射到端口443(SSL)的命令行腳本之一。當IIS最終循環應用程序池時,出現故障。 Rackspace更改了一些IP,但沒有正確重新映射證書。所以,這給我留下了MEX的挑戰,現在這個答案似乎處理了。謝謝! – 2010-01-19 20:27:48

相關問題