.AMSX 확장자없이 IIS 웹 서비스를 호출하십시오
-
03-07-2019 - |
문제
제 컨트롤 이외의 클라이언트가 소비 할 .NET 웹 서비스를 작성했습니다 (내 서버는 PHP로 작성된 라이브 서버의 시뮬레이터입니다). 웹 서비스는 원하는대로 작동하지만 클라이언트는 호출에 .AMSX 확장자 또는 해당 문제에 대한 확장을 추가 할 수있는 기능이 없습니다. 그들은 기본적으로 사용합니다 http : // localhost/soap/mywebservice IIS는 기대합니다 http : //localhost/soap/mywebservice.asmx. .AMSX 확장자없이 IIS가 요청에 응답 할 수있는 방법이 있습니까?
해결책
와일드 카드 매핑을 추가하면 ASP.NET을 통해 모든 요청을 라우팅합니다.
또한 수신 요청을 허용하려면 일부 URL 재 작성을 수행해야합니다. http://localhost/soap/MyWebService
지도에 http://localhost/soap/MyWebService.asmx
.
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
기본적으로 다음과 같은 것을 추가 할 수 있습니다. Application_BeginRequest
방법:
string path = Request.Path;
if (path.Contains("/soap/") && !path.EndsWith(".asmx"))
Context.RewritePath(path + ".asmx");
나는 그것을 테스트하지 않았지만 (그리고 그것은 해킹입니다) 당신을 시작해야합니다.
다른 팁
또한 디렉토리 자체에 넣은 다음 IIS에서 기본 문서로 설정할 수도 있습니다.
서버 : c :/mywebsite.com/mywebservice/mywebservice.asmx
IIS에서 MyWebService.asmx를 기본 문서로 설정했습니다
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.