0

我有一个在本地正常运行的 C# WCF 服务库。本地运行的客户端能够看到服务并使用它。但是,当我尝试将服务托管在 WebRole 中并将其部署在 Azure 上时,客户端永远无法像在本地那样成功地连接到它!我这样做的方式如下:

// The WCF Service library is in namespace: Root.Library    
Uri url = new Uri("http://xxx.cloudapp.net:8099/DealerService"); // tried also without "DealerService" but still didn't work
ServiceHost host = new ServiceHost(typeof(Root.Library.DealerService), url));
host.AddServiceEndpoint(typeof(Root.Library.IDealerService), new WSHttpBinding(), "DealerService");

ServiceMetadataBehavior dealerMetaBehavior = new ServiceMetadataBehavior();
dealerMetaBehavior.HttpGetEnabled = true;
host.Description.Behaviors.Add(dealerMetaBehavior);

host.Open();

在 Root.Library 中,app.config:

<service name="Root.Library.DealerService">
    <endpoint address="" binding="wsHttpBinding" name="dealer" contract="Root.Library.IDealerService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://xxx.cloudapp.net:8099/" />
      </baseAddresses>
    </host>
  </service>

我还在 WebRole 配置中添加了一个端点(类型:输入,协议:http,公共端口:8099)

谁能告诉我可能是什么问题???这真的让我很困惑!

非常感谢!

4

1 回答 1

0

您应该能够根据 csdef 文件更改端口

<Endpoints>
  <InputEndpoint name="Endpoint1" protocol="http" port="8888" />
</Endpoints>

Saqib Ullah 在 geekswithblogs 上有一篇文章,其中显示了更多信息:http ://geekswithblogs.net/technetbytes/archive/2011/04/25/145035.aspx

于 2012-07-31T05:33:21.070 回答