2010-12-22 74 views
0

我一直在爲此奮鬥了2天,但仍然無法正常工作。Azure AppFabric客戶端

我要去參加一個圖表流我的問題,使我的問題變得更加清晰: Google Docs PNG

這裏的整體問題:

我已經部署在Windows Azure和我一個簡單的WCF服務可以毫無問題地訪問它。現在,我確實想通過ServiceBus(即AppFabric)訪問這個相同的服務,這就是我陷入困境的地方。我在appfabric上創建了一個名稱空間,設置了5個連接包,然後我開始了!

這裏是我的服務定義(csdef)文件:

<?xml version="1.0" encoding="utf-8"?> 
<ServiceDefinition name="CRM5_WP7_GW"  xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> 
    <WebRole name="WCFGWServiceWebRole"> 
<Sites> 
    <Site name="Web"> 
    <Bindings> 
     <Binding name="Endpoint1" endpointName="Endpoint1" /> 
    </Bindings> 
    </Site> 
</Sites> 
<Endpoints> 
    <InputEndpoint name="Endpoint1" protocol="http" port="80" /> 
</Endpoints> 
<Imports> 
    <Import moduleName="Diagnostics" /> 
</Imports> 
<LocalResources> 
    <LocalStorage name="WCFServiceWebRole1.svclog" sizeInMB="1000" cleanOnRoleRecycle="false" /> 
</LocalResources> 

然後,這裏是我的serviceconfiguration(cscfg)文件:

<?xml version="1.0" encoding="utf-8"?> 
<ServiceConfiguration serviceName="CRM5_WP7_GW" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*"> 
    <Role name="WCFGWServiceWebRole"> 
    <Instances count="2" /> 
    <ConfigurationSettings> 
     <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /> 
    </ConfigurationSettings> 
    </Role> 
</ServiceConfiguration> 

現在最後一部分:我的控制檯應用程序(客戶):

namespace CRM5WP7HARDCLIENT 
{ 
    class Program 
    { 
    static void Main(string[] args) 
    { 

// create the service URI based on the service namespace 
Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("https", "myNameSpace", "myServiceName"); 

// create the credentials object for the endpoint 
TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior(); 
sharedSecretServiceBusCredential.CredentialType = TransportClientCredentialType.SharedSecret; 
sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerName = "issuerName"; 
sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerSecret = "issuerSecret"; 

// create the channel factory loading the configuration 

ServiceEndpoint sep = new ServiceEndpoint(ContractDescription.GetContract(typeof(IGWService))); 
sep.Address = new EndpointAddress(serviceUri); 
sep.Binding = new NetTcpRelayBinding(); 
sep.Binding = new BasicHttpRelayBinding(); 
ChannelFactory<IGWService> channelFactory = new ChannelFactory<IGWService>(sep); 

// apply the Service Bus credentials 
channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential); 


// create and open the client channel 
IGWService channel = channelFactory.CreateChannel(); 
System.Console.WriteLine("Opening channel..." + serviceUri.ToString()); 
((ICommunicationObject)channel).Open(); 
System.Console.WriteLine("Calling operation..."); 
System.Console.WriteLine(channel.HelloWorld()); 
System.Console.WriteLine("Done..."); 
System.Console.ReadKey(); 

((ICommunicationObject)channel).Close(); 
channelFactory.Close(); 
    } 
    } 
} 

正如你所看到的,我的服務有一個簡單的問候世界。 我的控制檯應用程序說「沒有服務託管在指定的位置」..

我試過改變的URI,嘗試玩配置多次,然後才結束與我現在有一個,但我的努力破產^ _^

如果你們有什麼想法,那會是太精彩了:)

提前

感謝您的建議和指導

乾杯 Miloud乙

+0

對不起,這是一個愚蠢的問題,但只是爲了確認 - 你把你的實際憑據到「證書中issuerName」和「issuerKey」?同樣的「myServiceName」? – Doobi 2010-12-23 07:02:02

回答

1

您的服務是Azure Web角色的主機嗎?如果是這樣,問題可能是,除非外部「激活」,WCF服務永遠不會創建到服務總線的出站連接。這種激活通常由IIS在向服務發出請求時完成。但是當使用服務總線時,服務主機需要主動啓動這個項目。

您可能要參考本博客文章:http://www.wadewegner.com/2010/05/host-wcf-services-in-iis-with-service-bus-endpoints/

+0

謝謝!我現在得到正確的方向;) – CoolStraw 2010-12-23 10:36:04