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
ConfigExceptionInfo:
Notification: EXECUTE_REQUEST_HANDLER
ErrorCode: The operation completed successfully. (0x0)


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

How can find out what's "bad"
BrianFordAsked:
Who is Participating?
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.
0
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"
0
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.
0

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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

BrianFordAuthor Commented:
ah , I see sorry,

I've never used the Application_BeginRequest option so I'll need to figure that out :)
0
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="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope" <soap:Body><checkGp xmlns="http://cwpfiis/CRLServices"><tagNum>12345</tagNum></checkGp></soap:Body></soap:Envelope>
0
BrianFordAuthor Commented:
Duy

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

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

Best Regards,
Duy.
0
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
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.