Please Login to Continue

Free Software Development Articles.Email List
How to Draw Realistic Photos (E-Book)

How to Draw Realistic Photos (E-Book)

$1

Why Software Development Need Ethics to Succeed (E-Book)

Why Software Development Need Ethics to Succeed (E-Book)

$1

How to Make a Social Media Website in Easy Steps

How to Make a Social Media Website in Easy Steps

$1

Solved: How NOT To Show XML In Json Returned By ASMX WebService

Problem:
Returning pure JSON when using SMX web service is somehow critical to passing data from the server to the client (Mobile Phones, Websites etc).
For almost six months I have had a problem where I did not want JSON to be returned wrapped up in XML strings for example: 

 xmlns="http://tempuri.org/">
"[{\"OrderId\":2,\"UserId\":null,\"FirstName\":\"Mack\",\"LastName\":\"Erick\",\"Phone\":\"218-098-

This created problems when trying to call the API using angularJS when JSON has to be returned and read in a promise. The error that was thrown was Cannot Read Data At Position 0 >. 

Solution:
How I solved this annoying problem is by synthesizing the function in the Webservice so that it does not return a String, instead to have Void defined
Public void NameOfFunction(String API_Key){
//DoSomthing In Here
//Check For API and Logic
//Do not return anything (Its Void)
Then the breakthrough came
//Convert Object/String/Data to JSON
//Just write the context Response
Context.Response.Write(JsonObJect Or String Or Whatever value you want)
//Then just call the function from the website or an App
}





Technology published
Buy Me Coffee

Was this page helpful?

Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful..



© 2020 - ErnesTech - Privacy