2012-12-11 65 views
0

我使用VS2008和.NET 3.5。如何在IIS 5.1中託管WCF服務?

這是我的情況:

1)外部服務:

我使用外部服務(沒有關於它的任何代碼的知識;它是黑盒子對我來說),並調用它的方法,它有幾個參數。其中之一是我應該寫的WCF服務地址(見2))。通話看起來如下:

string Url = "http://public-ip:8072/Service.svc"; 
string content = extClient.Method1(Url, email, param1, param2...); 

在方法1的身體的某個地方,他們稱我從2)的服務。

2)我的服務:

public class Service : IService 
{ 
    public const string ReplyAction = "http://public-ip:8072/Message_ReplyAction"; 
    public const string RequestAction = "http://public-ip:8072/Message_RequestAction"; 

    public Message SetData(Message requestXml) 
    { 
     // Do something 
    } 
} 

Web.config文件:

<system.serviceModel> 
    <serviceHostingEnvironment> 
    <baseAddressPrefixFilters> 
     <add prefix="http://public-ip:8072/"/> 
    </baseAddressPrefixFilters> 
    </serviceHostingEnvironment> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior name="Parus.ServiceBehavior"> 
     <serviceMetadata httpGetEnabled="true" httpGetUrl="http://local-ip:8072/Service.svc"/> 
     <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <services> 
    <service behaviorConfiguration="Parus.ServiceBehavior" name="Parus.Service"> 
     <endpoint address="http://public-ip:8072/Service.svc" binding="basicHttpBinding" contract="Parus.IService"> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> 
    </service> 
    </services> 
</system.serviceModel> 

我的服務工作,當我在本地使用它,但不會當我把它暴露給世界。我的意思是來自1)的Method1根本不叫它。我嘗試過不同的事情,但目前爲止沒有任何反應。防火牆關閉時不起作用。另外,當添加防火牆端口8072的例外時,它不起作用。

我想在我的Web.config文件中有錯或者錯過了IIS中的一些設置。您可以在Web.config文件中關注public-ip和local-ip地址。也許我犯了錯誤。我不確定。

+0

與論壇網站不同,我們不使用「謝謝」或「任何幫助表示讚賞」,或對[so]進行簽名。請參閱「[應該'嗨','謝謝',標語和致敬從帖子中刪除?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be –

+0

好吧,我明白了 – tesicg

回答

0

當服務通過公共IP地址,通常是兩件事情之一,但當地沒有工作:

  • 防火牆阻塞請求。在這裏我看到你寫道你打開了這個港口。嘗試使用telnet進行測試,也許有幾個圖層會阻塞端口,而您只能打開一個圖層。
  • 該配置。您在web.config中混合使用公共和私有IP地址,嘗試將所有內容都設置爲公用IP地址。
+0

我希望我的服務不僅可以在本地公開,而且可以在互聯網上公開 – tesicg

+0

我在我的Web.config文件中設置了所有的地址爲相同 - 公共IP,但是一切都一樣,這意味着我的服務沒有執行 – tesicg

+0

我真的不知道下一步該怎麼做 – tesicg