我正在使用 Microsoft.XMLHTTP 调用来调用一个 Web 服务:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "/xxx/Converter.asmx/Convert", false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send("conversionFolder=" + escape(conversionFolder));
if (xmlhttp.status == 200) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(xmlhttp.responseText);
... more stuff ...
return str;
}
else {
alert(xmlhttp.statusCode + " - " + xmlhttp.statusText);
}
当我记得在本地的web.config文件中添加HttpPost协议时,一切都正常运行:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<webServices>
<protocols>
<add name="HttpPost"/>
</protocols>
</webServices>
<compilation debug="false"></compilation>
</system.web>
<system.codedom>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
</system.webServer>
</configuration>
但是在一个生产服务器上,它在运行了 1-2 天后会失败。在 asp.net 进程被回收后,它可以正常工作。它可以正常工作 1-2 天,然后出现以下错误:
Exception information:
Exception type: InvalidOperationException
Exception message: Request format is unrecognized for URL unexpectedly ending in '/Convert'.
Request information:
Request URL: https://xxx/xxx/converter.asmx/Convert
Request path: /xxx/converter.asmx/Convert
User host address: 195.50.35.4
User: extranet\kbk
Is authenticated: True
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 14
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
at System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
为什么它要等待两天才会失败?我该怎么做才能防止它失败?这是否与此服务器运行在HTTPS模式有关?