unmarshalling xml/json - spring-mvc

Using google map RESTful api to buidl a sample spring mvc project.
I am able to consume the API using Jersey Client.
The response can either be xml/json
XML format is
What would be the best way to deserialize this data so that I can obtain individual response elements like duration/ distance?
appreciate any advise or useful learning links.
This may go against forum rules, but if during answering my question, if anyone knows of a good spring mvc book, can you recommend it in the answer?

Related

Is there an efficient way to implement an interceptor for http requests on SwiftUI?

Looking for an efficient way to implement interceptors in SwiftUI for any HTTP requests made on my app. The App uses JWT's to authenticate and fetch users specific data. As such I want to simplify token management and refresh using an interceptor. Have seen this be done in angular and was wondering if there is a SwiftUI framework or methedology to simplify the implementation.
Thanks!
I have looked into using Alamofire, however the framework looks outdated and I was unsure if it was still valid to use in a production setting.
Overall its been fairly difficult to find up to date resources in regards to this topic which has made it hard to experiment between different solutions.

Is it possible to convert my web API to an OData API?

Context:
I have an existing Web API of the following form:
http://site/api/{area}?slicer1=alpha&slicer1=beta&starttime=sometime&endtime=sometime
It's implemented in ASP MVC. The API's function processes the parameters and feeds them into a SQL query. On success, it returns a IHttpActionResult with JSON data from SQL.
Note that the API lacks an entity model or entity relationship diagram. It's essentially just a wrapper around a SQL query.
Question:
Recently, I started learning about OData. It seems like OData is designed for the URL itself to control how data is filtered, as opposed to authoring a custom SQL query to filter.
Hence, I'd like an answer on whether my Web API could be converted to an OData API and, if so, what OData capabilities I'd need to do that (for instance, might OData v4 functions be useful)?
Clarifications:
I don't have any code written, nor am I asking for code as an answer.
I am looking to know what OData capabilities might enable my scenario (v4 functions, actions, etc...), or if OData and Web APIs are so different that my ask doesn't make sense.
Anticipating the "Why are you asking" this questions - I'm just interested in technically feasibility as a learning exercise.
You could switch to a OData API but if you have no entities, i.e. no IQueryable to query, you'd still have to do the SQL command generation by yourself. It's not too hard though - we did it in the project I'm working in.
You also have to ask yourself to what extent you want to switch to OData. For example, you could decide to just use its (type-safe) query-string parsing capabilities and from the parsed filter tree generate your own SQL (as mentioned above).
On the other hand, having a fully fledged OData API would also dictate the response format to comply to the standard. This would mean that you can start connecting to your API using OData aware tools (e.g. Excel, KendoUI Grid, etc.). I don't know if that would give you any benefit for your use-case.
Your question
what OData capabilities I'd need to do that
is not exactly clear to me. There are no OData capabilities that would help you to migrate from a Web API to an OData API. OData is just a set of standardized query (CRUD) and response formats. You can also be OData compliant by implementing all on your own using out-of-the-box Web API facilities but probably you'd want to use the Web API OData package.
The most important question for you is to ask yourself what advantage you'd have using OData.

OAuth (OAuth2) ASP.NET REST Web API (Self host - windows service) implementation

I have built a Restful Web API for my (android) mobile application, and now i am trying to secure the access to the API. I was reading for about a week on this topic and i got the whole spectrum - from those who say that is is impossible to secure a Restful API to those who say that Https (SSL) is enough.
Here I don't want to start a discussion about that.I have settled with OAuth or OAuth2 it doesn't matter(as far as I have read OAuth seems to be the better choice, but in the Microsoft tutorials they use OAuth 2, so here i am quite confused), and yes i know that they are completely different, but I am so frustrated of searching that I would accept either (I must admit that I expceted this to be much easier). As I said, I was searching for about a week, and all I got are concepts(a lot of them). You send some data -magic start - usually username/password to the server, your data is being processed and you get a token back - magic stop-. On SO there are a lot of questions on this topic but most of the answers are unprecise (and unfortunately unusuable). For example I got this one How to secure WEB API, nice answers, but not really use of them, or this one Implement Web API with OAuth and a Single Page Application. I also got the examples from the Microsoft tutorials but there is a lot of overhead in the code and the part about OAuth isn't quite clear(which is unfortunate because the whole example should be about OAuth). I could post tons of links which claim to talk about this topic, but actually they are of no help.
What I am looking for is an simple, very very simple, example of an ASP.NET OAuth(2) implementation. It would be great if I just could use it with fiddler, provide an username/password in the header and with use of grant_type: xxx I get the token back(the permitted username/password can be hard coded inside the project, so no need for Entity framework implementation or any database on the backend). And it would also be great if someone could explain me how to use this token to authorize the user (I got it that I have to provide the Controller functions with the [Authorize] attribute, but how and where is this token-check being done ?). But please, don't post any theory about OAuth, I don't need that, here I am looking for the actual implementation of OAuth inside of Asp.Net Web Api
thanks
Here is detailed post about adding the resource owner password credentials flow for your Web API project.
The most simple implementation of OAuth2 in Web API project you can find here:
WebApiOAuth2 on GitHub
There are just two important files:
Startup.cs (with settings)
AuthorizationServerProvider.cs (authorization of users using oauth2)

Retrieving google analytics data with Tibco BW

I would like to extract data with google analytics api to tibco Business works. But i am not sure what the best pratice would be. First i thought about using java code for requests and responses. I have been looking at this tutorial.
https://developers.google.com/analytics/solutions/articles/hello-analytics-api
But now i am not sure if that is the best idea. Would it be better or even possible to do with Tibco:s http-palettes? Can i autenticate i user then? I would appreciate if someone could point me in the right direction.
Yes, you can use the BW HTTP Activities to integrate with the Google Analytics' RESTful API. However, to make things easier, you might want to consider using the BW Plugin for REST and JSON, which will take care of the JSON parsing and OAUTH implementation for you.
Otherwise, the easiest option is to just use the Google's Java Client Library and BW's Java Activities

How to use a SOAP API in ASP.NET?

I've trying to use the API for CapsuleCRM...
http://capsulecrm.com/help/page/api_gettingstarted
I've been reading some articles on SOAP in asp.net and I just don't get it. Most of them seem to be ablut creating a web service, not using it and none of them seem to explain how to use basic HTTP authentication.
I have got as far as constructing the XML i want to send to the API but I could really do with seeing some example code which makes an http call using http authentication to a SOAP API.
Maybe I'm just searching for the wrong thing but I've drawn a blank so far. Can anybody show me how?
Jon
Actually, the interface in question is REST - not SOAP.....
Check out the WCF REST Developer Center for a great intro on how to do REST based calls to REST based API's like this one. Lots of articles, lots of screencasts showing how to do things, from consuming the simplest service to more advanced topics.
Highly recommended!
See a comparison of REST vs SOAP for a few insights.

Resources