How to run WCF service on a specific port

后端 未结 4 1407
轻奢々
轻奢々 2020-12-20 12:49

I have a .Net 4.0 WCF service running on IIS. I have not specified a port so assume it is running on port 80. I need to install my service on a server where port 80 is alrea

相关标签:
4条回答
  • 2020-12-20 13:27

    We can do it using the .csproj file of the WCF project(in case of using VS).Just change the value of this xml tag in your corresponding file:

    To Run the service at port number 60000 ,

    <DevelopmentServerPort>60000</DevelopmentServerPort>
    
    0 讨论(0)
  • 2020-12-20 13:40

    I am assuming you are running your services on net.tcp protocols.

    1) Edit your bindings (right click Default Web Site select Edit Bindings

    enter image description here

    2) Server Side

    <service name="YouServiceNameSpace.YourService">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="YourBinding" contract="YourContract" />
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
    </service>
    

    3) Client Side

     <endpoint address="net.tcp://YourHost:443/YourServiceDirecotry/YourService.svc"
        behaviorConfiguration="YourBehavior" binding="netTcpBinding"
        bindingConfiguration="YourTcpBinding" contract="YourContract"
        name="YourContractName" />
    
    0 讨论(0)
  • Normally you should have a services node with at least one service node and each having endpoints, where you can specify the port. See more at: http://msdn.microsoft.com/en-us/library/ms733932.aspx

    For example:

    <services>
      <service name="MyNamespace.myServiceType">
       <endpoint 
          address="net.tcp://0.0.0.0:8000" binding="basicHttpBinding" 
          bindingConfiguration="myBindingConfiguration1"
          contract="MyContract"  />
      </service>
    </services>
    
    0 讨论(0)
  • 2020-12-20 13:41

    Specify the port in the address of the endpoint. See the 'Defining Endpoint Addresses in Code' section in this article for more details.

    0 讨论(0)
提交回复
热议问题