Status Code 400 calling.NET web service form iOS

I have a .NET Web Service that works just fine when called form various web pages.

When I call it from an iOS App using Swift I get a 400 Bad Request error, there is no other information in either the event log or HTTP logs on the IIS server to indicate what the issue is.

The IIS FailedRequestLog states:

ModuleName: ManagedPipelineHandler
Notification: 128
HttpStatus: 400
HttpReason: Bad Request
HttpSubStatus: 0
ErrorCode: 0
ErrorCode: The operation completed successfully. (0x0)

The response returned to the app is simply "status code: 400"

How can find out what's "bad"
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Duy PhamFreelance IT ConsultantCommented:
Sometimes, it might be result of unhandled exception in your Web Service code. It's hard to give even just a guess about problem without sample code (client/service). Maybe you should try to enable Tracing in your Web Service and then log all the needed information (including the Request, steps in Web Service methods, etc.) to find out where is the real problem is.
BrianFordAuthor Commented:
Like I mentioned above, tracing is enabled but the only thing in there is the trace entry I included in the original post "400 Bad Request"
Duy PhamFreelance IT ConsultantCommented:
What I meant is Tracing for your ASP.NET Web Service, not just IIS. And maybe you should log everything you get from client on Application_BeginRequest, and double check them with working calls from other web pages as you mentioned in description of this thread.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

BrianFordAuthor Commented:
ah , I see sorry,

I've never used the Application_BeginRequest option so I'll need to figure that out :)
BrianFordAuthor Commented:
Thanks so much, enabling that tracing has highlighted an error, although I'm not sure why it's an issue, but the error I'm getting in the log is:

"System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.Xml.XmlException: Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 1, position 207."

The XML sent by the client is: (position 207 is the start tag for the soap:Body)
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="" <soap:Body><checkGp xmlns="http://cwpfiis/CRLServices"><tagNum>12345</tagNum></checkGp></soap:Body></soap:Envelope>
BrianFordAuthor Commented:

Thank you so much, I actually figured out I had a missing closing tag and everything work great now

Thanks again
Duy PhamFreelance IT ConsultantCommented:
Glad that it would help :).

Best Regards,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.