在 C# 中使用 SOAP Web 服务处理格式错误的 XML 标记
Handling malformed XML tag using SOAP Web Service in C#
我已经创建了一个 ASMX Web 服务来处理来自第三方应用程序的请求。我使用了他们提供给我们的 WSDL 作为请求和响应的规范。我已满足这些要求并启动了我的服务 运行。我可以使用 Storm. When we try to access the web service from the third party app, the request fails, so we setup WireShark 来测试应用程序以观察请求。
我们从数据包捕获中看到的是“[InvalidOperationException]:无法识别 URL 意外以 /MyMethodName 结尾的请求格式”。通过一些研究,我发现 this article。我们试过了,并开始收到不同的错误消息。这是错误 message/stack:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
我已经尝试了 SO 文章中的大部分建议,并决定退后一步,从 Web 配置中一起删除 Web 服务协议。所以,回到原点。经过进一步调查,我注意到发送到我们的 Web 服务的请求包含格式错误的 XML 声明。
<?requestXml version='1.0' encoding='UTF-8'?>
这可能是我头痛的原因吗?如果是这样,我该如何处理?我显然不能对第三方应用程序进行更改。
我确实必须创建一个通用处理程序来处理这个问题。 XML 解析器不关心 XL 声明标记格式错误。
我已经创建了一个 ASMX Web 服务来处理来自第三方应用程序的请求。我使用了他们提供给我们的 WSDL 作为请求和响应的规范。我已满足这些要求并启动了我的服务 运行。我可以使用 Storm. When we try to access the web service from the third party app, the request fails, so we setup WireShark 来测试应用程序以观察请求。
我们从数据包捕获中看到的是“[InvalidOperationException]:无法识别 URL 意外以 /MyMethodName 结尾的请求格式”。通过一些研究,我发现 this article。我们试过了,并开始收到不同的错误消息。这是错误 message/stack:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
我已经尝试了 SO 文章中的大部分建议,并决定退后一步,从 Web 配置中一起删除 Web 服务协议。所以,回到原点。经过进一步调查,我注意到发送到我们的 Web 服务的请求包含格式错误的 XML 声明。
<?requestXml version='1.0' encoding='UTF-8'?>
这可能是我头痛的原因吗?如果是这样,我该如何处理?我显然不能对第三方应用程序进行更改。
我确实必须创建一个通用处理程序来处理这个问题。 XML 解析器不关心 XL 声明标记格式错误。