对于在“/转换”中意外结束的URL,请求格式无法识别1-2天后发生

时间:2011-06-23 20:42:51

标签: asp.net web-services https xmlhttprequest asmx

我正在使用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)

为什么在失败前等待2天?我该怎么做才能防止它失败? 它是否与此服务器以HTTPS模式运行这一事实有关?

3 个答案:

答案 0 :(得分:1)

什么是Dot Net框架? IIS 6或7?
您是否尝试在协议部分添加<add name="HttpGet"/>。似乎有些人已经解决了这个问题。 (但不是所有人)
link 1
link 2
还要检查部署站点的位置。它是在Web服务器的根级别还是虚拟文件夹中。有时它可能会从父级别站点或machine.config文件继承一些配置值。

否则可能与代码中的某些内存泄漏有关。你如何处理加载的XML。 我还假设您正在解析有效的XML。

答案 1 :(得分:1)

似乎有一个修补程序可用于回收应用程序池时将问题解决了几天: http://support.microsoft.com/kb/2783777/en-us

答案 2 :(得分:0)

默认情况下协议似乎已停用。 Stackoverflow中已经回答了类似的问题。请查看此link和相关的question