[英]How to host WCF service in IIS 5.1?
我使用VS2008和.NET 3.5。
這是我的情況:
1)外部服務:
我使用外部服務(對它的代碼一無所知;對我來說這是黑匣子),並調用需要幾個參數的方法。 其中之一是我應該編寫的WCF服務地址(請參閱2)。 該呼叫如下所示:
string Url = "http://public-ip:8072/Service.svc";
string content = extClient.Method1(Url, email, param1, param2...);
在Method1主體的某個位置,他們從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地址。 也許我對他們犯錯了。 我不確定。
當服務在本地運行但不通過公共IP地址運行時,通常是以下兩種情況之一:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.