简体   繁体   中英

Handling malformed XML tag using SOAP Web Service in C#

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.

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:

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.

<?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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM