【发布时间】:2012-01-12 15:19:24
【问题描述】:
我有一个托管 WCF 服务的 Windows Azure WorkerRole。此服务应由 Silverlight 应用程序使用。在本地,这工作正常,但是,当我尝试部署它时,需要在角色配置中配置端点(见下图)。
当我删除那个端点“WCFEndpoint”时,一切都在本地正常工作。但是,当它存在时,会发生以下异常:
System.ServiceModel.AddressAlreadyInUseException:HTTP 连接 URL "http://+:9196/GreenwayService/" nicht registrieren, weil der TCP-Port 9196 von einer anderen Anwendung verwendet wird。
英文意思是:HTTP could not register URL "...", because the TCP PORT 9196 is used by another application.
据我了解,端点需要像图片中那样定义,以便在云内部可以访问。
这是我的 app.config:
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type=""/>
</add>
</listeners>
</trace>
</system.diagnostics>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><system.serviceModel>
<services>
<service name="Greenway.AzureWorkerRole.ServiceHosting.CrossDomainService">
<endpoint address="" behaviorConfiguration="HttpEnableBehavior"
binding="webHttpBinding" contract="Greenway.AzureWorkerRole.ServiceHosting.ICrossDomainService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:9196/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="GreenwayServiceBehavior" name="Greenway.AzureWorkerRole.ServiceHosting.GreenwayService">
<endpoint address="" binding="basicHttpBinding" contract="Greenway.AzureWorkerRole.ServiceHosting.IGreenwayService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:9196/GreenwayService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="HttpEnableBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="GreenwayServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
这是启动服务的代码 sn-p:
ServiceHost greenwayServiceHost = new ServiceHost(typeof(GreenwayService));
ServiceHost crossDomainServiceHost = new ServiceHost(typeof(CrossDomainService));
greenwayServiceHost.Open();
crossDomainServiceHost.Open();
为了在云中托管服务,我需要在这三个地方进行哪些更改?
【问题讨论】:
标签: wcf azure cross-domain