问题描述
假设我们有一个响应主机标题的网站kebab-shop.intra.net
Say we have a website that responds to a host header "kebab-shop.intra.net"
此URL中是否可以同时包含SOAP和RESTful ?
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 /...
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.
到目前为止的想法
- 单独的主机标题,例如添加
kebab-shop-rest.intra.net
- 单独的网站
理想情况下,我想拥有一个网站,一个域名,一个主机头。零机会?
Ideally, I'd like to have one web site, one domain name, one host header. Zero chance?
这是带有.net 4的IIS 6.我们有一些大型企业限制,这意味着我们仅限于一个zip文件放入网站使用的相关文件夹。这旨在允许我们的客户迁移,而不会产生大型企业支持,基础架构和部署开销。共存只会持续一个月或三个月。
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.
编辑:我问,因为我不是网络开发人员。如果我的条款错了,这就是为什么......
I'm asking because I'm not web developer. If my terms are wrong, this is why...
所以......我想要 kebab-shop.intra上的SOAP和REST。 IIS 6上的net
没有复杂性。
So... I want both SOAP and REST on kebab-shop.intra.net
on IIS 6 without complexity.
推荐答案
* kebab-shop.intra.net/takeaway.asmx
* kebab-shop.intra.net/kebab/get/...
是的,这肯定是可能的。如果您有一个WCF服务,则可以轻松地为同一服务公开两个单独的端点 - 一个使用例如 basicHttpBinding
(大致相当于ASMX),另一个 webHttpBinding
(REST)。
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).
完整的URL必须不同 - 但我相信第一部分可以是相同的。
The complete URL's must be different - but the first part can be the same, I believe.
如果你在IIS6中托管,你需要一个虚拟目录,这将部分决定你的SOAP端点 - 它必须是这样的:
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
(或: http://kebab-shop.intra.net/YourVirtDir/takeaway.asmx
如果您坚持使用ASP.NET遗留Web服务。)
(or: http://kebab-shop.intra.net/YourVirtDir/takeaway.asmx
if you insist on using an ASP.NET legacy webservice).
和REST端点可以位于同一个虚拟目录中并定义URI模板,例如你可以这样:
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
或类似的网址。
但是: 我自己检查一下,我发现你不能让两个服务端点都在同一个基地址实时 - 其中一个必须有另一个与之相关的相对地址。
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.
所以要么添加例如SOAP到您的SOAP端点
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
这篇关于在同一个URL上运行SOAP和RESTful的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!