没有的.asmx分机呼叫的IIS Web服务 [英] Call an IIS Web Service without the .asmx extension

查看:172
本文介绍了没有的.asmx分机呼叫的IIS Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了.NET Web服务要由我控制之外的客户端使用(我的服务器是一个模拟器为用PHP编写的一个活的服务器)。 Web服务作为工作所需,但客户端没有添加的.asmx扩展名,或者任何扩展为此事,在他们的呼叫。他们基本上使用的http://本地主机/ SOAP /为MyWebService 而IIS预计的 HTTP://localhost/soap/MyWebService.asmx 。有没有什么办法能让请求IIS响应无的.asmx扩展?

I have written a .NET web Service that is to be consumed by a client outside of my control (my server is a simulator for a live server written in PHP). The web service works as desired but the client does not have the ability to add the .asmx extension, or any extension for that matter, in their calls. They basically use http://localhost/soap/MyWebService while IIS expects http://localhost/soap/MyWebService.asmx. Is there any way to make IIS respond to requests without the .asmx extension?

推荐答案

添加一个通配符映射,这将借道ASP.NET的所有请求:

Add a wildcard mapping, which will route all requests through ASP.NET:

<一个href="http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx">http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx

你也需要做一些URL重写,以允许传入的请求的http://本地主机/ SOAP /为MyWebService 映射到 HTTP://localhost/soap/MyWebService.asmx

You'll also need to do some URL rewriting, to allow the incoming request http://localhost/soap/MyWebService to map to http://localhost/soap/MyWebService.asmx.

<一个href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx">http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

基本上,你可以添加类似下面的内容到你的的Application_BeginRequest 方法:

Basically, you could add something like the following to your Application_BeginRequest method:

string path = Request.Path;
if (path.Contains("/soap/") && !path.EndsWith(".asmx"))
    Context.RewritePath(path + ".asmx");

我没有测试它(和它的一个黑客),但它应该让你开始。

I haven't tested it (and it's a HACK) but it should get you started.

这篇关于没有的.asmx分机呼叫的IIS Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆