请求格式不被识别,URL以'/Convert'结尾,1-2天后发生。

29

我正在使用 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模式有关?


你确定它是因为时间间隔而失败,而不是因为无效的输入?从错误信息来看,它显示URL意外结束了?你如何解决这个问题,你能自动化解决方案,以避免停机时间吗? - Robert
这与对象没有被正确释放有关吗?您是否在服务中使用了“外部”对象,例如COM,而这些对象未被正确释放? - AYK
很抱歉我没有答案,但我可以说我们有完全相同的问题。我们的 ASMX Web 服务似乎会在随机时间停止工作,并出现您所遇到的相同错误。我们每晚都会进行回收。这并不是每天或甚至每周都会发生。我在这里是因为系统运行了15个小时后它又再次发生了。我们一直无法将其与任何性能计数器相关联。 - Larry Silverman
3个回答

1

1
什么是Dot Net框架?IIS 6或7?您尝试在协议部分添加<add name="HttpGet"/>,这似乎是一些人用来解决问题的方法(但不是所有人)。链接1链接2。还要检查您的站点部署位置。它是在Web服务器的根级别还是虚拟文件夹中?有时它可能会从父级站点或machine.config文件继承一些配置值。否则,它可能与代码中的某些内存泄漏有关。您对加载的XML做了什么?我假设您正在解析有效的XML。

0

看起来协议默认是禁用的。在Stackoverflow上已经有一个类似的问题得到了回答。请检查此链接和相关问题


@Brian - 这是你的生产环境中的问题吗? - Cid
这不是同一件事。我遇到了与此处描述的完全相同的问题。我找到了您提到的那个问题,并检查了解决方案是否可行,结果发现建议的设置已经存在。 - Jonathan van de Veen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接