Azure AppFabric服务总线回显示例不工作

Azure AppFabric服务总线回显示例不工作,azure,appfabric,Azure,Appfabric,我正在尝试在本地网络上的两台计算机之间运行Echo示例。该示例使用netcprelaybinding,如果我在同一台机器上运行服务和客户端,它就可以正常工作。 当我第一次编译服务并将其放在我的另一台机器上时,它是一台没有安装开发工具的Windows2003服务器。它不会运行,因为它不知道app.config中的netcprelaybinding是什么。因此,我将配置移到“仅代码”,服务启动。我通过服务总线浏览器确认了这一点。 然后我尝试连接我的开发机器(通过VS2010),但它无法工作。我尝试过

我正在尝试在本地网络上的两台计算机之间运行Echo示例。该示例使用netcprelaybinding,如果我在同一台机器上运行服务和客户端,它就可以正常工作。 当我第一次编译服务并将其放在我的另一台机器上时,它是一台没有安装开发工具的Windows2003服务器。它不会运行,因为它不知道app.config中的netcprelaybinding是什么。因此,我将配置移到“仅代码”,服务启动。我通过服务总线浏览器确认了这一点。 然后我尝试连接我的开发机器(通过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();
//基于服务命名空间创建服务URI
Uri serviceUri=ServiceBusEnvironment.CreateServiceUri(“sb”,serviceNamespace,“EchoService”);
//为端点创建凭据对象
TransportClientEndpointBehavior sharedSecretServiceBusCredential=新TransportClientEndpointBehavior();
sharedSecretServiceBusCredential.CredentialType=TransportClientCredentialType.SharedSecret;
sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerName=IssuerName;
sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerSecret=IssuerSecret;
//创建加载配置的通道工厂
//ChannelFactory ChannelFactory=newchannelfactory(“RelayEndpoint”,新端点地址(serviceUri));
//习俗
ServiceEndpoint端点=新的ServiceEndpoint(新的合同描述(“IEchoContract”、“Microsoft.ServiceBus.Samples”)、新的NetCPRelayBinding(EndToEndSecurityMode.Transport、RelayClientAuthenticationType.None)、新的端点地址(serviceUri));
ChannelFactory ChannelFactory=新的ChannelFactory(端点);
//自定义端
//应用服务总线凭据
channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
//创建并打开客户端通道
IEchoChannel=channelFactory.CreateChannel();
通道打开();

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

这是因为实验室的名称空间与“旧”appfabric不同。我现在不知道如何让它工作。差不多又是“微软”了……

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

我遇到了相同的问题,然后我指出,这个示例需要您自己的服务总线。 因此,在门户中创建一个服务总线,然后将颁发者密钥的值复制到颁发者机密