Question

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?

Was it helpful?

Solution

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

http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx

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.

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

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.

OTHER TIPS

You could also put it in a directory by itself, then in IIS set it as a default document.

On server: C:/mywebsite.com/mywebservice/mywebservice.asmx

In IIS set mywebservice.asmx as a default document

On the web: http://mywebsite.com/mywebservice

It seems to me that there's something very wrong with the PHP client. They should not be interepreting the URL for the service in any way. Whatever URL is specified in server metadata or client configuration is the URL they should use.

I don't know PHP, but can anyone tell me why it makes any sense for PHP to care how many dots there are in a URL? I can't see that it should matter to any client whether my service is at http://localhost/foo/bar or "http://localhost/foo/b.a.r.asmx?PHP=0".

In php you have to call the wsdl only, you don't need the asxm or that kind of stupid things that .net do.

one simple example

$wsdl = "http://domain/wsdlfile.wsdl"; //url to wsdl 
$client = new SoapClient($wsdl,array('trace' => 1,'encoding' => 'UTF-8','exceptions' => 0)); 
$Return = $client->callfunction();
echo htmlspecialchars($client->__getLastResponse());

that's all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top