Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wcf Azure AppFabric客户端_Wcf_Azure_Appfabric - Fatal编程技术网

Wcf Azure AppFabric客户端

Wcf Azure AppFabric客户端,wcf,azure,appfabric,Wcf,Azure,Appfabric,我已经为此挣扎了两天,但我仍然无法让它工作 我将在我的问题中加入一个图表流程,以便我的问题变得更清楚: 以下是总体问题: 我在WindowsAzure上部署了一个简单的WCF服务,我可以毫无问题地访问它。现在,我确实希望通过ServiceBus(即AppFabric)访问相同的服务,这就是我遇到的问题。我已经在appfabric上创建了一个名称空间,设置了一组5个连接,然后我就开始了 以下是我的服务定义(csdef)文件: 然后,这里是我的服务配置(cscfg)文件: 现在是最后一

我已经为此挣扎了两天,但我仍然无法让它工作

我将在我的问题中加入一个图表流程,以便我的问题变得更清楚:

以下是总体问题:

我在WindowsAzure上部署了一个简单的WCF服务,我可以毫无问题地访问它。现在,我确实希望通过ServiceBus(即AppFabric)访问相同的服务,这就是我遇到的问题。我已经在appfabric上创建了一个名称空间,设置了一组5个连接,然后我就开始了

以下是我的服务定义(csdef)文件:


然后,这里是我的服务配置(cscfg)文件:


现在是最后一部分:我的控制台应用程序(客户端):

命名空间CRM5WP7HARDCLIENT
{
班级计划
{
静态void Main(字符串[]参数)
{
//基于服务名称空间创建服务URI
Uri serviceUri=ServiceBusEnvironment.CreateServiceUri(“https”、“myNameSpace”、“myServiceName”);
//为端点创建凭据对象
TransportClientEndpointBehavior sharedSecretServiceBusCredential=新TransportClientEndpointBehavior();
sharedSecretServiceBusCredential.CredentialType=TransportClientCredentialType.SharedSecret;
sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerName=“IssuerName”;
sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerSecret=“IssuerSecret”;
//创建加载配置的通道工厂
ServiceEndpoint sep=新的ServiceEndpoint(ContractDescription.GetContract(typeof(IGWSService));
sep.Address=新的端点地址(serviceUri);
九月绑定=新的netcprelaybinding();
sep.Binding=new basichtpreaybinding();
ChannelFactory ChannelFactory=新的ChannelFactory(sep);
//应用服务总线凭据
channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential);
//创建并打开客户端通道
IGWService channel=channelFactory.CreateChannel();
System.Console.WriteLine(“打开频道…”+serviceUri.ToString());
((ICommunicationObject)通道).Open();
System.Console.WriteLine(“调用操作…”);
System.Console.WriteLine(channel.HelloWorld());
System.Console.WriteLine(“完成…”);
System.Console.ReadKey();
((ICommunicationObject)通道).Close();
channelFactory.Close();
}
}
}
正如你所注意到的,我的服务有一个简单的hello world。 我的控制台应用程序显示“指定位置没有托管服务”

我已经尝试过更改URI,尝试过多次使用配置,最后得到了我现在拥有的配置,但我的努力失败了^_^

如果你们有什么想法,那就太好了:)

提前感谢您的建议和指导

干杯
Miloud B

您的服务主机是Azure Web角色吗?如果是这样,问题可能是除非在外部“激活”,否则WCF服务永远不会创建到服务总线的出站连接。此激活通常由IIS在向服务发出请求时完成。但在使用服务总线时,服务主机需要主动启动此项目


您可能想参考这篇博客文章:

对不起,这是一个愚蠢的问题,但只是想确认一下-您是否将您的实际凭证放入了“issuerName”和“issuerKey”中?对于“myServiceName”也是如此,特别是对于这个场景,如果您没有任何IIS或ASP.NET依赖项,我发现在WorkerRole上托管WCF服务更容易,因为您可以更好地控制服务的整个生命周期。
<?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>
<?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();
   }
  }
 }