0

I was recently assigned the task of creating a login page for my company and they're requiring that I use angularjs for the client side application.

The authenication services are asp.net web services that have already been coded, and return xml because of another service that also uses them.

I notice that AngularJS wants JSON data for it's return value.

I need a way of using AngularJS http methods get and post that will work with data from and to the web server using SOAP. My recent attempts have consisted of trying to get the xml back and then convert it to json on the client side.

Converting on client-side can potentially have problems and so I would prefer to keep all conversations on the server-side.

My solution would be something like have all my web services working as normal. Then have one web service that can take another method in as a parameter and call that method in code and return a json string.

Can anyone give me some input on this. My reason behind not wanting to simply change the web services to return json is because other applications use this service and are expecting xml, also there are more than 1000 web methods in place.

I may have found a solution I am going to work towards. However, if any viable options are still available that would simply add a new method to the list of web methods that would be great. Talking with the developer that wrote all the web services I will need to be using it would be simpler to convert the xml to json on client-side. I am also looking into some angular modules that people have written for get, post for soap services. Found here

After lots of digging around the best option for me is to use this code Here. I can make the call easily and once I get the xml back just do angular.fromJson(angular.toJson(response)).

theB
  • 6,450
  • 1
  • 28
  • 38
Bailey Miller
  • 219
  • 2
  • 12
  • Possible duplicate http://stackoverflow.com/questions/20664311/convert-xml-data-to-json-format-angularjs – jbrown Jun 06 '16 at 14:20
  • How are these existing XML endpoints written? Are they WCF, asmx, asp.net MVC controller actions? This influences what you can do with them. My first instinct would be to shift to something like Web API which has [content negotiation built in](http://www.asp.net/web-api/overview/formats-and-model-binding/content-negotiation) so it will do the work for you. Especially if they are currently MVC endpoints, the transition is smoother – Rhumborl Jun 06 '16 at 14:35
  • I didn't write them myself I am fairly sure they're using asmx – Bailey Miller Jun 06 '16 at 14:51
  • 2
    Possible duplicate of [How to handle XML services in AngularJS?](http://stackoverflow.com/questions/15490658/how-to-handle-xml-services-in-angularjs) – Mitch Jun 06 '16 at 15:13
  • I read through that question originally however, the difference is my question asks if having a single method capable of taking in other methods as a param is a viable option. – Bailey Miller Jun 06 '16 at 15:15

1 Answers1

0

If ASP.NET WebAPI is used on the server side it may be sufficient to add an Accept header with the value application/json to the HTML request. It tells the server to return JSON instead of XML.

fknx
  • 1,775
  • 13
  • 19