2014-06-25 110 views
0

我有一個wcf服務,並使用控制檯應用程序作爲我的服務的主機。當我使用這樣的基地址:<baseaddres ="http://ipaddress:8080/" />。當我通過Web瀏覽器檢查我的服務操作時,我可以打開服務WSDL並且工作正常。wcf服務主機僅在端口號8080上運行

但是,當我將端口號更改爲別的。服務主機可以正常啓動(沒有使用過的端口號或其他)。當我去檢查服務是否通過網絡瀏覽器運行時,該服務未被顯示。最終我的客戶也找不到該服務。

的app.config配置

<services> 
    <service name="Natatorium_WCF.NatatoriumService" 
      behaviorConfiguration="ServiceBehavior"> 
    <endpoint address="NatatoriumService" 
       binding="wsHttpBinding" 
       contract="Natatorium_WCF.INatatoriumService" 
       bindingConfiguration="wsHttpBindingConfig"> 
    </endpoint> 
    <endpoint address="NatatoriumService" 
       binding="netTcpBinding" 
       contract="Natatorium_WCF.INatatoriumService" 
       bindingConfiguration="netTcpBindingConfig" > 
    </endpoint> 
    <endpoint address="mex" 
       binding="mexHttpBinding" 
       contract="IMetadataExchange"/> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://[ServerName]:[PortNO.1]"/> 
     <add baseAddress="net.tcp://[ServerName]:[PortNO.2]"/> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 

這是主機代碼來啓動該服務(控制檯應用程序)。

static void Main(string[] args) 
    { 
     ChangeServerConfigFileAttributeValue("8080", "8090"); 
     using (ServiceHost host = new ServiceHost(typeof(Natatorium_WCF.NatatoriumService))) 
     { 
      host.Open(); 
      Console.WriteLine("Listening..."); 
      Console.ReadLine(); 
     } 
    } 
+0

您有任何防火牆或端口限制? –

+0

我們可以看到配置嗎? – paramosh

+0

我不知道如何檢查防火牆,順便說一下我的防火牆關閉@TMcKeown –

回答

0
<configuration> 
<system.serviceModel> 
<services> 

    <service name="HelloService.HelloService" behaviorConfiguration="mexBehaviour"> 
    <endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService" ></endpoint> 
    <endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService" ></endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:8080/"/> 
     <add baseAddress="net.tcp://localhost:8090/"/> 
     </baseAddresses> 
    </host> 

    </service> 

</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="mexBehaviour"> 
     <remove name="serviceDebug"/> 
     <serviceMetadata httpGetEnabled="true"/> 
    </behavior> 
    </serviceBehaviors> 


</behaviors> 

+0

我有這就是我對AppConfig的 –

+0

寫的是錯誤代碼相同的錯誤? –

相關問題