Is it viable to consume XML Response from a Webservice by posting xml using angular JS. Any suggestions would be helpfull.
One option can be just convert the xml object to the json object
https://code.google.com/p/jquery-xml2json-plugin/
Related
I have an api controller which generates response as xml and need to pass this xml to an external angularjs application and parse this to show result.
I have tried this so far.
/PaymentSuccess.html?response=<xml>....<xml>
I dont think this is the best way of doing because the uri seems lengthy and ugly.
Is there any better way so that i can pass the xml to the uri and read that from the angular application.
Recently I started to work with Web API. I work ok, but I want to return data in json. It now returns records in XML. Please guide me
Chrome does that by default, it return xml if you simply try your URL in the browser. There is a way to tell the api to only return json, you basically have to remove the xml serialiser and only leave in the json one:
configuration.Formatters.Clear();
configuration.Formatters.Add(new JsonMediaTypeFormatter());
reference :
http://www.strathweb.com/2013/06/supporting-only-json-in-asp-net-web-api-the-right-way/
I am working in MVC 4 and using angularJs for client side scripting.I made an edit method which posts Id of the object to the MVC controller.When i click on edit . The url it generates is http://localhost:59568/NewsLetter/GetNewsLetterDataAng?id=%2256d6ac05afb241256469194b%22
but it should be
http://localhost:59568/NewsLetter/GetNewsLetterDataAng?id=56d6ac05afb241256469194b
Because of extra %22 in the front and end it is throwing 500 error.
Please suggest me how to remove it from the url
To complete the comment above I'll let you know an other thing about how to send and get data using angular js.
If you want to pass a json object to the server it's better to do it in a POST using the $http service builtin angular like in the example below:
$http.post(url, jsonObject){...};
By doing so, you send the json object as the body of the request and in asp.net-mvc the model binder can bind that json object to a class in your C# code.
In your case there is no need, as I said in the comments, for the JSON.stringfy method call when doing a GET request.
I'm not able to fetch data from xml using backbone.js. No proper example is given on the sites I checked.
Take a look at BackboneJS with XML ajax
Basically, you need to overwrite the model/collection's parse method to build an object form the XML response.
In addition, you need to overwrite the requested data type, as it is json by default.
I've been working on Basecamp API integration and I find it too sluggish using Cakephp's HttpSocket, Xml loader using Set::reverse. Anyone have tried working similar?
What my code does is provide the API token as required by Basecamp parsed Xml into array and return parsed XML to calling procedures.
I'm not sure if I understood your qestion right, but maybe the XML helper is what you are looking for.