2013-02-26 12 views
5

私は、Webサイトとwcfサービスを含むazureにwebroleをデプロイしています。
サイトはwcfのサービスを消費します。ここ
問題はtheresの場合、私は「予測」するのいずれかの方法を思ったんだけど...ステージング展開がエンドポイントのために狂気のURLを作成し、私はweb.configファイル内のエンドポイントを変更しておく必要があることをAzureのステージングクレイジーURLを扱う

ですどのようなURLになるか、または強制的に1つまたは "localhost"のような汎用ホストを指して?

+0

を、MSのAzureフィードバックサイト上で、それのための提案があります。 [投票やコメントを追加できます](http://feedback.windowsazure.com/forums/169386-cloud-services-web-and-worker-role-/suggestions/1282603-pick-a-dns-name-ステージング用)。 – Co7e

答えて

1

からWCFサービスのURLを更新することです終点。これを参照してくださいhereblog postにリンクします。

ぼんやりしたサービスに接続するための自分の抽象基本クラスは、その記事に基づいていました。私は(ステージングを参照する必要はありません

this.roleName = "WebServiceRole"; 
this.endpointName = "HttpInternal"; 
this.serviceName = "services/Accounts.svc"; 

#region Channel 
    protected String roleName; 
    protected String serviceName; 
    protected String endpointName; 
    protected String protocol = @"http"; 

    protected EndpointAddress _endpointAddress; 
    protected BasicHttpBinding httpBinding; 
    protected NetTcpBinding tcpBinding; 

    protected IChannelFactory channelFactory; 
    protected T client; 

    protected virtual AddressHeader[] addressHeaders 
    { 
     get 
     { 
      return null; 
     } 
    } 

    protected virtual EndpointAddress endpointAddress 
    { 
     get 
     { 
      if (_endpointAddress == null) 
      { 
       var endpoints = RoleEnvironment.Roles[roleName].Instances.Select(i => i.InstanceEndpoints[endpointName]).ToArray(); 
       var endpointIP = endpoints.FirstOrDefault().IPEndpoint; 
       if(addressHeaders != null) 
       { 
        _endpointAddress = new EndpointAddress(new Uri(String.Format("{1}://{0}/{2}", endpointIP, protocol, serviceName)), addressHeaders); 
       } 
       else 
       { 
        _endpointAddress = new EndpointAddress(String.Format("{1}://{0}/{2}", endpointIP, protocol, serviceName)); 
       } 

      } 
      return _endpointAddress; 
     } 
    } 

    protected virtual Binding binding 
    { 
     get 
     { 
      switch (protocol) 
      { 
       case "tcp.ip": 
        if (tcpBinding == null) tcpBinding = new NetTcpBinding(); 
        return tcpBinding; 
       default: 
        //http 
        if (httpBinding == null) httpBinding = new BasicHttpBinding(); 
        return httpBinding; 
      } 
     } 
    } 

    public virtual T Client 
    { 
     get 
     { 
      if (this.client == null) 
      { 
       this.channelFactory = new ChannelFactory<T>(binding, endpointAddress); 
       this.client = ((ChannelFactory<T>)channelFactory).CreateChannel(); 
       ((IContextChannel)client).OperationTimeout = TimeSpan.FromMinutes(2); 
       var scope = new OperationContextScope(((IContextChannel)client)); 
       addCustomMessageHeaders(scope); 
      } 
      return this.client; 
     } 
    } 
    #endregion 

そして、私はそれを(例えば)以下の変数を渡す派生クラス内:それは、このようなチャネルクレートに役割の発見を使用していますまたは制作)URLをまったく使用しないでください。

詳細はこちら私の答えを参照してください:MSは、一貫性のあるステージングURLやIPのためのオプションを追加したい人のためAdd WCF reference within the same solution without adding a service reference

0

GUIDを予測したり、制御したり、定数名を使用する方法はありません。あなたは物事を簡単にするために、何ができる

は、あなたがWCFを見つけるために、役割の発見を使用することができるはず.CSCFGにURLを移動し、Azureの管理ポータル

関連する問題