Call the IIS web service without the .asmx extension

I wrote a .NET web service that should be used by a client outside my control (my server is a simulator for a real server written in PHP). The web service works as desired, but the client is not able to add the .asmx extension or any extension, if necessary, to its calls. They mainly use http: // localhost / soap / MyWebService , while IIS expects http: //localhost/soap/MyWebService.asmx . Is there a way to get IIS to respond to requests without the .asmx extension?

+3
source share
4 answers

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

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

You will also need to do some redrawing the URLs to allow the incoming request to http://localhost/soap/MyWebServicematch http://localhost/soap/MyWebService.asmx.

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

Basically, you can add Application_BeginRequestsomething like the following to your method :

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

I have not tested it (and this is HACK), but it should start you up.

+7
source

You can also put it in a directory yourself, then in IIS set it as the default document.

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

IIS mywebservice.asmx

: http://mywebsite.com/mywebservice

+4

, - PHP. URL- - . , URL , URL, .

PHP, - , PHP , URL-? , , http://localhost/foo/bar http://localhost/foo/b.a.r.asmx?PHP=0".

0

php wsdl, asxm , .net.

$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());

.

0

Source: https://habr.com/ru/post/1704177/


All Articles