3

Say we have a website that responds to a host header "kebab-shop.intra.net"

Is is possible to have both SOAP and RESTful in this URL?

That is, both of these are handled within the deployed code.

  • kebab-shop.intra.net/takeaway.asmx
  • kebab-shop.intra.net/kebab/get/...

I've been told this can't be done, without much explanation. Like this answer. This could be, I'm a database monkey, but I'd like some thoughts on what options I do or don't have please.

Thoughts so far

  • Separate host headers eg add kebab-shop-rest.intra.net
  • Separate web sites

Ideally, I'd like to have one web site, one URL domain name, one host header. Zero chance?

This is IIS 6 with .net 4. And we have some large corporate limitations that mean we are limited to a zip file to drop into the relevant folder used by the web site. This is intended to allow our clients to migrate without incurring the large corporate support, infrastructure and deployment overhead. The co-existence will only be for a month or three.

Edit: I'm asking because I'm not web developer. If my terms are wrong, this is why...

So... I want both SOAP and REST on kebab-shop.intra.net on IIS 6 without complexity.

Community
  • 1
  • 1
gbn
  • 422,506
  • 82
  • 585
  • 676
  • Can you clarify what you mean by "one web site, one URL, one host header."? Your app will always serve multiple URLs... – Carles Barrobés Feb 04 '11 at 18:08
  • @Carles Barrobés : one web site in IIS 6 that is accessed by "kebab-shop.intra.net". Ignoring /kebab/get etc. – gbn Feb 04 '11 at 18:11
  • that one is clear, but what about "one URL", "one host header"? What is your "one URL"? – Carles Barrobés Feb 04 '11 at 18:14
  • @Carles Barrobés: in which case, I don't understand your question sorry. I want to have one DNS CNAME entry on which requests are routed to one web site. Anything after "kebab-shop.intra.net" is irrelevant. – gbn Feb 04 '11 at 18:19
  • @gbn: You should clarify your question. You absolutely cannot have a SOAP service and a REST service on the same URL, but you certainly can have them served up from the same web server/same domain name. – Jim Ferrans Feb 04 '11 at 18:44
  • @Jim Ferrans: yes, this sounds like what I should be asking – gbn Feb 04 '11 at 18:52

2 Answers2

4

That is, both of these are handled within the deployed code.

* kebab-shop.intra.net/takeaway.asmx
* kebab-shop.intra.net/kebab/get/...

Yes, that should definitely be possible. If you have a single WCF service, you could easily expose two separate endpoints for the same service - one using e.g. basicHttpBinding (roughly equivalent to ASMX), and another with webHttpBinding (REST).

The complete URL's must be different - but the first part can be the same, I believe.

If you're hosting in IIS6, you need one virtual directory and that will partly dictate your SOAP endpoint - it will have to be something like:

http://kebab-shop.intra.net/YourVirtDir/takeaway.svc

(or: http://kebab-shop.intra.net/YourVirtDir/takeaway.asmx if you insist on using an ASP.NET legacy webservice).

and the REST endpoint can live inside the same virtual directory and define URI templates, e.g. you could have something like:

http://kebab-shop.intra.net/YourVirtDir/TakeKebab/gbn

or similar URL's.

However: checking this out myself I found that you cannot have both service endpoints "live" off the same base address - one of them has to have another "relative address" associated with it.

So either you add e.g. "SOAP" to your SOAP endpoint

http://kebab-shop.intra.net/YourVirtDir/takeaway.svc/SOAP/GetKebab
http://kebab-shop.intra.net/YourVirtDir/TakeKebab/gbn

or you add something to your REST service

http://kebab-shop.intra.net/YourVirtDir/takeaway.svc/GetKebab
http://kebab-shop.intra.net/YourVirtDir/REST/TakeKebab/gbn
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • We need to separate the REST by a virtual folder in IIS 6? The asmx will be dropped ASAP of course... – gbn Feb 04 '11 at 18:33
  • @gbn: no, you can have both service types in a single virtual directory - but one of the two needs to have an additional "relative" address, e.g. you cannot have both living at "http://yourServer/VirtualDirectory/YourService.svc" – marc_s Feb 04 '11 at 21:30
3

I don't see a reason why you can't. Typìcally your SOAP endpoints will be one specific URLs per service, whereas for resources exposed via REST you will have one URL per resource (following 'URL patterns').

Example URLs for SOAP:

http://kebab-shop.intra.net/soap/service1    
http://kebab-shop.intra.net/soap/service2

Example URL patterns for REST:

http://kebab-shop.intra.net/rest/{resourcetype}/{id}/

e.g.: http://kebab-shop.intra.net/rest/monkeys/32/

etc...

Carles Barrobés
  • 11,608
  • 5
  • 46
  • 60