0

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.

WEFX
  • 8,298
  • 8
  • 66
  • 102
  • 1
    `WebHttpBinding` does have a constructor (it has a few); what do you mean you can't find one? – carlosfigueira May 23 '13 at 23:18
  • I mean I'm not able to write a similar chunk of code that says var binding = new WebHttpBinding... "WebHttpBinding" isn't a recognized class. I am already using System.ServiceModel, so I don't know of any other needed reference. – WEFX May 24 '13 at 00:10
  • 1
    Add reference to System.ServiceModel.Web.dll? – carlosfigueira May 24 '13 at 04:53
  • Alright, I didn't have that dll added in my References, so Intellisense wasn't even suggesting I add it to my using statements. Please add an answer and I'll accept it. Thanks – WEFX May 24 '13 at 12:27

1 Answers1

1

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.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171