Call an IIS Web Service without the .asmx extension

前端 未结 4 1094
逝去的感伤
逝去的感伤 2020-12-10 20:48

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 work

相关标签:
4条回答
  • 2020-12-10 21:04

    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.

    0 讨论(0)
  • 2020-12-10 21:10

    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

    0 讨论(0)
  • 2020-12-10 21:12

    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.

    0 讨论(0)
  • 2020-12-10 21:17

    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".

    0 讨论(0)
提交回复
热议问题