0

別の呼び出しが来ているときに WCF 呼び出しを行いたい状況があります。

Site1 request--> Site2
Site2 request --> Site3
Site2 <-- Site3 response
Site1 <-- Site2 response

私が抱えている問題は、Site1 が Site2 に送信している間に Site2 が Site3 にメッセージを送信しようとしたときです。Site2 は、Site3 が見つからないと言っています。

実際のエラー メッセージは次のとおりです。

Could not find endpoint element with name 'Endpoint_IEchoService' and contract 
'FakeCompany.API.Services.Contract.IEchoService' in the ServiceModel client 
configuration section. This might be because no configuration file was found 
for your application, or because no endpoint element matching this name could be 
found in the client element.

各サイトは同じ構成とコード ベースです。クライアント、プロキシ、およびサーバーはすべて同じプロジェクトにあります。アプリは互いに呼び出し合うクローンです。これは、複数のアドレス バインディングを持つ 1 つの Web サイトです。サイト間の他の通常の通話は、通話内で通話を試みるまで正常に機能します。

連絡先の名前から推測できると思いますが、私のエコー サービスではそれほど複雑な処理は行われていません。サイト間のシングル エコー コールは機能します。私の問題は、サービス側で別のサイトへのカスケード呼び出しを行うときです。

これが許可されていないのか、構成設定の変更が必要なのか疑問に思っています。

いくつかのコードと構成。

エンドポイント アドレスは実行時に変更されます。
「ファンキー」なものが表示される場合、それはクライアント、プロキシ、およびサービスがジェネリック基本クラスから継承されているためです。

//-- ServiceModel クライアント

<endpoint address="http://FakeCompany.unittest/Services/EchoService.svc"
 binding="basicHttpBinding" bindingConfiguration="SecureBinding"
 contract="FakeCompany.API.Services.Contract.IEchoService" name="Endpoint_IEchoService">
    <identity>
        <servicePrincipalName value="host/mikev-ws" />
    </identity>
</endpoint>

//-- バインディング

<bindings>
    <basicHttpBinding>
        <binding name="SecureBinding" 
                 maxReceivedMessageSize="10000000" 
                 sendTimeout="00:05:00">
            <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Basic" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>

//-- 振る舞い

<behaviors>
    <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
    </serviceBehaviors>
</behaviors>

//-- サービス

<service name="FakeCompany.API.Services.Service.EchoService" behaviorConfiguration="MyServiceTypeBehaviors">
    <endpoint address="" binding="basicHttpBinding" contract="FakeCompany.API.Services.Contract.IEchoService" bindingConfiguration="SecureBinding" />
</service>

// - テスト

[Test]
public void CascadeMessage()
{
    //-- TEST: That a wcf call can occur within another wcf call.

    //-- ARRANGE
    DTO_Echo_Cascade_Request request = new DTO_Echo_Cascade_Request(unit1, unit2);
    request.NextCall = string.Format("{0};{1};{2};", unit3, unit4, unit5);


    //-- ACT
    var response = EchoAgent.Cascade(request);

    //-- ASSERT
    Assert.AreEqual("TBA", response.Response);
}

// - エージェント

internal static DTO_Echo_Response Cascade(DTO_Echo_Cascade_Request request)
{
    DTO_Echo_Response response;
    using (EchoServiceClient serviceClient = new EchoServiceClient(request))
    {
        response = serviceClient.Cascade(request);
    }

    return response;
}

// - クライアント

public DTO_Echo_Response Cascade(DTO_Echo_Cascade_Request request)
{
    return Process(() => Proxy.Cascade(request));
}

CONTRACT、DTO、PROXY は省略されています。

// - サービス

public DTO_Echo_Response Cascade(DTO_Echo_Cascade_Request request)
{
    DTO_Echo_Response response = new DTO_Echo_Response();

    response.Response += string.Format("Hello from {0};", request.TargetAddress);

    if (request.NextCall.NotNullOrEmpty())
    {
        var split = request.NextCall.Split(new [] {';'}, StringSplitOptions.RemoveEmptyEntries);

        if (split.GetUpperBound(0) > 0)
        {
            DTO_Echo_Cascade_Request nextRequest = new DTO_Echo_Cascade_Request(request.TargetAddress, split[0]);
            for (int i = 1; i < split.GetUpperBound(0); i++)
            {
                nextRequest.NextCall += split[i] + ";";
            }
            response.Response += EchoAgent.Cascade(nextRequest).Response;
        }

    }

    return response;
}

次の行で例外が発生します

response.Response += EchoAgent.Cascade(nextRequest).Response;
4

0 に答える 0