Azure AppFabric Service Bus Echo示例无法正常工作

时间:2010-12-06 22:26:41

标签: azure appfabric

我正在尝试在本地网络上的两台计算机之间运行Echo示例。该示例使用netTcpRelayBinding,如果我在同一台机器上运行服务和客户端,它可以正常工作。 当我第一次编译服务并将其放在我的其他计算机上时,安装了dev工具的Windows 2003 Server。它不会运行,因为它不知道app.config中的netTcpRelayBinding是什么。所以我将配置仅移动到代码并启动了服务。我通过Service Bus Explorer确认了这一点。 然后我尝试连接我的开发机器(通过VS2010),但它不起作用。我试图改变服务和客户端的东西,尝试我能想到的所有设置组合,但没有。 我主要在客户端上遇到两个错误之一:

“ContractDescription'IEchoContract'没有任何操作;合同必须至少有一个操作。”

“没有可以接受消息的端点侦听”。

这是服务器代码,我的更改是在自定义注释之间。

// create the service URI based on the service namespace
        Uri address = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "EchoService");

        // 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 service host reading the configuration
        ServiceHost host = new ServiceHost(typeof(EchoService), address);

        // custom
        host.AddServiceEndpoint(
                    typeof(IEchoContract),
                    new NetTcpRelayBinding(),
                    "EchoService" );
        // custom end

        // create the ServiceRegistrySettings behavior for the endpoint
        IEndpointBehavior serviceRegistrySettings = new ServiceRegistrySettings(DiscoveryType.Public);

        // add the Service Bus credentials to all endpoints specified in configuration
        foreach (ServiceEndpoint endpoint in host.Description.Endpoints)
        {
            endpoint.Behaviors.Add(serviceRegistrySettings);
            endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
        }

        // open the service
        host.Open();

这是客户端代码,我当前的更改是在自定义注释之间:

// create the service URI based on the service namespace
        Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, "EchoService");

        // 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
        //ChannelFactory<IEchoChannel> channelFactory = new ChannelFactory<IEchoChannel>("RelayEndpoint", new EndpointAddress(serviceUri));

        // custom
        ServiceEndpoint endpoint = new ServiceEndpoint(new ContractDescription("IEchoContract", "Microsoft.ServiceBus.Samples"), new NetTcpRelayBinding(EndToEndSecurityMode.Transport, RelayClientAuthenticationType.None), new EndpointAddress(serviceUri));
        ChannelFactory<IEchoChannel> channelFactory = new ChannelFactory<IEchoChannel>(endpoint);
        // custom end


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

        // create and open the client channel
        IEchoChannel channel = channelFactory.CreateChannel();
        channel.Open();

我的app.config文件已清除设置。我没有触及任何其他文件。

3 个答案:

答案 0 :(得分:1)

这是因为实验室的命名空间与“旧”appfabric不同。我不知道如何让它正常工作。几乎就是“微软”......

答案 1 :(得分:0)

我遇到了同样的问题,当我调试它时,我发现来自配置的issuerKey是“yourkey”。这些值存储在Azure项目本身ServiceConfiguration.cscfg文件中。你需要在那里放置一些真正的值,它应该没问题。

答案 2 :(得分:0)

我遇到同样的问题,我想,这个例子需要你自己的服务总线。 因此,在门户中创建一个服务总线,然后将发行者密钥的值复制到issure secret。

相关问题