سؤال

I have to manually configure a ServiceReference in my project, because my project uses a secondary config file, and I’ve run into a lot of problems trying to read from that file. I was able to get things working by manually defining a basicHttpBinding instance on my client as follows:

var binding = new BasicHttpBinding
{
    Name = "something",
    CloseTimeout = new TimeSpan(0, 1, 0),
    OpenTimeout = new TimeSpan(0, 1, 0),
    ReceiveTimeout = new TimeSpan(0, 10, 0),
    SendTimeout = new TimeSpan(0, 1, 0),
    AllowCookies = false,
    //and so on...
};

However, I’m not able to make test calls to my web service via a browser, unless I change the server-side binding to webHttpBinding. With webHttpBinding, browser-requests to my service return serialized data as expected. But, requests from my clients fail because they are using basicHttpBinding.

How do I define a WebHttpBinding object instead of a BasicHttpBinding object? I can’t find a constructor, even though one is listed in MSDN.

هل كانت مفيدة؟

المحلول

The class WebHttpBinding is in the System.ServiceModel.Web.dll - you need to add a reference to it. In the future you can check the type's MSDN reference for the assembly where it lives on.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top