English 中文(简体)
WCF客户的开放式(开放式)方法在安全残疾后不再放弃例外情况。 怎么办?
原标题:WCF client s Open() method no longer throw exceptions after security is disabled. What to do?
  • 时间:2012-04-18 17:33:11
  •  标签:
  • c#
  • .net
  • wcf

我有一个WCF服务——客户。 我们一直依靠公开招标,使用客户工厂方法,确保在我们发出任何呼吁之前提供服务。 类似:

MyClient GetClient() 
{
    MyClient client = new MyClient();
    try
    {
        client.Open();
        return client;
    }
    catch(Exception)
    {
        //perform an (important) error-handling here
    }
}

这样,打电话者守则就能够做到:

client = factory.GetClient();
client.CallMethodInTheService();

他们不必担心错误处理。

当我们为Windows和客户CredentialType设定安全模式时,客户(Open()在无法提供服务时将放弃一个例外,因此,错误处理法将得到执行。 然而,我们现在是在我们不能使用视窗成像安全的环境中部署的,因此,我们把安全模式设定为零。 然而,这会造成客户。 开放(开放)不再成为无法提供服务的例外情况,而且我们有一些问题,因为我们在工厂的集水区依靠这一守则。

What is the reason that Open() throws an exception when we use message security but not when we disable the security? How can we perform similar availability checking if security is set to none? I don t think it s a good solution to put a try catch with error handling on each individual call. Is there another way for the factory method to check the availability of the service before returning the client object?

最佳回答

The exception will not be thrown with any security but only in cases where a session is involved. e.g. establishSecurityContext=true or negotiateServiceCredentials=true (the defautls). In those cases before the first call to the server the client will send some infra messages to it in order to decide on a cryptogtaphic key to use. When you call open() you explicitly ask to make this negotiation now (otherwise it will happen on the first call). If you turn on Wcf logging (or Fiddler) you will see this.

如果服务无法操作,谈判就会失败,使你成为例外。

没有安全就没有会议例外。

I suggest you add a IsAlive operation to the service.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签