0

I have a WCF Service application, in which I have some Rest Services and some conventional WCF services.

I have added a HttpModule to intercept the service calls to the Rest service and verify the token in the request header and allow access to the service. This works fine for my Rest services.

When I make call to the WCF service, it goes to the HTTPModule and then I get the exception at the client side "The remote server returned an unexpected response: (400) Bad Request."

How do I make sure that my HttpModule is only invoked for Rest services, but not for my WCF Soap services.

KhanS
  • 1,167
  • 2
  • 12
  • 27

1 Answers1

1

I guess you can't, since both methods (REST and SOAP) use the GET and POST verb so you can't filter on that.

Try to put both services in a different path, where each path gets its own module.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • What do you mean by putting in different paths. – KhanS May 10 '12 at 08:28
  • @KhanS assign the appropriate [module](http://learn.iis.net/page.aspx/121/iis-modules-overview/) to its own application. So you'll have `http://yourhost/RESTServices/foo.bar` and `http://yourhost/SOAPServices/foo.svc`, where the first is handled by your REST module and the latter by the WCF module. – CodeCaster May 10 '12 at 08:32
  • why doesn't my call reaches the WCF service after it returns from the HTTPModule. Any idea ? – KhanS May 10 '12 at 11:16
  • Because a WCF (.svc) call should be handled by the `System.ServiceModel.Activation.HttpHandler`. Your handler probably captures all requests (*). – CodeCaster May 10 '12 at 11:22