在C#中使用SOAP Web服务处理格式错误的XML标记

时间:2022-04-30 15:22:50

I have created an ASMX Web Service to handle requests from a third party application. I used a WSDL that they gave us as specs for the request and response. I have matched those requirements and have my service up and running. I can test the application just fine using Storm. When we try to access the web service from the third party app, the request fails, so we setup WireShark to watch the requests.

我创建了一个ASMX Web服务来处理来自第三方应用程序的请求。我使用了他们给我们的WSDL作为请求和响应的规范。我已满足这些要求并启动并运行我的服务。我可以使用Storm测试应用程序。当我们尝试从第三方应用程序访问Web服务时,请求失败,因此我们设置WireShark来查看请求。

What we saw from the packet captures is "[InvalidOperationException]: Request format is unrecognized for URL unexpectedly ending in /MyMethodName". With a little research, I found this article. We tried that and started receiving a different error message. This was the error message/stack:

我们从数据包捕获中看到的是“[InvalidOperationException]:对于意外以/ MyMethodName结尾的URL无法识别请求格式”。通过一些研究,我发现了这篇文章。我们尝试了并开始收到不同的错误消息。这是错误消息/堆栈:

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)

I have tried most of the suggestions from the SO article, and decided to take a step back and remove the web service protocols all together from the web config. So, back to square one as it were. After further investigation, I noticed that the request being sent to our web service has what I would consider a malformed XML declaration.

我已经尝试了SO文章中的大部分建议,并决定退后一步,从Web配置中一起删除Web服务协议。所以,回到正方形的原样。在进一步调查之后,我注意到发送到我们的Web服务的请求具有我认为的格式错误的XML声明。

<?requestXml version='1.0' encoding='UTF-8'?>

Could this be the cause of my headaches? If so, how do I handle this? I obviously can't make changes to the third party application.

这可能是我头痛的原因吗?如果是这样,我该如何处理?我显然无法对第三方应用程序进行更改。

1 个解决方案

#1


0  

I did have to create a generic handler to handle this issue. The XML parser didn't care that the XL declaration tag was malformed.

我必须创建一个通用的处理程序来处理这个问题。 XML解析器并不关心XL声明标记是否格式错误。

#1


0  

I did have to create a generic handler to handle this issue. The XML parser didn't care that the XL declaration tag was malformed.

我必须创建一个通用的处理程序来处理这个问题。 XML解析器并不关心XL声明标记是否格式错误。