开发者

Azure AppFabric client

I've been struggling with this for 2 days yet and I'm still unable to get it working.

I'm going to join a diagram flow to my question so that my problem gets clearer: Google Docs PNG

Here's the overall issue:

I have a simple WCF service deployed on Windows Azure and I can access it with no problem. Now, I do want to access this same service through ServiceBus (ie AppFabric) and this is where I get stuck. I've created a name space on appfabric, set a pack of 5 connections and there I start !

Here's my servicedefinition (csdef) file:

<?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>

Then, here's my serviceconfiguration (cscfg) file:

<?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>

Now the last part: My console app (the client):

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.Co开发者_如何学Cnsole.WriteLine("Calling operation...");
System.Console.WriteLine(channel.HelloWorld());
System.Console.WriteLine("Done...");
System.Console.ReadKey();

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

As you can notice, my service has a simple hello world. My Console app says "No service hosted at the specified location"..

I've tried changing the URI, tried playing with the configuration multiple times before I end up with the one am having now but my efforts went bankrupt ^_^

If you guys have any idea, that's gonna be too wonderful :)

Thanks in advance for your suggestions and directions

Cheers Miloud B


Is your service host in an Azure Web Role? If so, the problem may be that unless "activated" externally, the WCF service is never creating the outbound connection to the service bus. This activation is typically done by IIS when a request is placed to the service. But when using the service bus, the service host needs to actively initiate this project.

You may want to refer to this blog article: http://www.wadewegner.com/2010/05/host-wcf-services-in-iis-with-service-bus-endpoints/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜