How to fix WrongInputException in ASP.NET Core?
Asked Answered
B

1

0

I want to use a SOAP web service prepared by another team, used internally in my new REST API prepared in ASP.NET Core. My web service client code was scaffolded with WCF Web Service Reference Provider Tool. I cleaned up code (e.g. I changed property and method names) according to my team's naming convention.

When I send requests by my new REST API, I received WrongInputException. I checked all the parameters from an example request, all of them are in the same place in my C# code consuming scaffolded client.

I don't know what message exactly is sent by my new REST API.

Bortman answered 29/12, 2020 at 11:12 Comment(0)
B
0

In my case, the main cause of the described behavior and WrongInputException was premature refactoring. I changed the names of properties in the web service client without knowledge of the consequences.

E.g. if the element in the request body is objectRefNum, then I cannot simply change the related property in the scaffolded service reference class, because - without extra configuration - that name is copied with the same letter case to the request body of the SOAP envelope. The SOAP envelope should be encoded in the case-sensitive mode.

To trace the raw request body send by my new REST API in ASP.NET Core, I followed instructions from this excellent answer.

(Note, BTW, that kind of error (applying inappropriate letter case) could be handled by IDE, at least as a warning, but it is not, so: we need to be careful when we make refactoring, even if we have unit tests covering all the paths, and even if we use semantic renaming supported by IDE.)

Bortman answered 29/12, 2020 at 11:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.