2010-12-22 76 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