我有一个在本地正常运行的 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)
谁能告诉我可能是什么问题???这真的让我很困惑!
非常感谢!