Jax-rs URI call - jax-rs

I'm using HttpClient to access some api(Kubernetes) but I want to switch to jax-rs. Can the same functionality be achieved from Jax-rs? I was accessing the APIs in a java function. I'm a newbie to jax-rs and so far I know that it's use to create APIs.
Any help would be appreciable.

https://docs.oracle.com/javaee/7/api/javax/ws/rs/client/package-summary.html is the package summary for the javax.ws.rs.client package. with examples and directions below. Basically,
use a ClientBuilder to get a Client (with heavyweight/common stuff
like http/https parameters)
Create a WebTarget to denote an endpoint (including template placeholders)
Resolve that target (to get another WebTarget) with parameters
Invoke it to get and process the results (comes back in a Response object)

Related

Accessing HTTP headers in GraphQL v17

Currently, I am using a custom context object in my GraphQL application. It is built via a class that extends GraphQLServletContextBuilder. In version 17, they have deprecated the use of the context object. Our app is using the custom context to get access to a variable in the HTTP header to make it available to resolvers via the DataFetchingEnvironment variable added to resolver functions.
I cannot seem to find how to replicate get access to HTTP headers in a resolver function outside of using a custom context object. We're using the built in servlet as part of the GraphQL kickstart package. The only way I've seen referenced so far on how to get anything into the new context is by setting the context via the ExecutionInput call. And that call is buried in their servlet.
The example I've seen:
var executionInput = ExecutionInput.newExecutionInput()
.query(query)
.variables(variables)
.graphQLContext(Map.of(CustomContext.class, context));
I don't necessarily need a custom context object (especially since it's eventually going away), I just need to know how to get access to an HTTP header inside a resolver function if a custom context is no longer the way to do it going forward.

How can I cosume a GET REST call and mapping to a java bean (object) through Apache Camel?

I am new in apache camel. I want to do a GET REST call to get data and then I want to mapping these data to my Java bean. How can I do that with camel? I want to do it in a spring MVC web application.
I know how to do it with RestTemplate for example, but I want to use apache camel.
I've checked this documentation http://camel.apache.org/cxfrs.html but still I don't know how to set up for accomplishing this.
Please if you can provide some examples will be great.
There are a few different options. I'll walk through one...
First, define your rest configuration with bindingMode=auto
restConfiguration()
.component("jetty").host("0.0.0.0").port(9000)
.bindingMode(RestBindingMode.auto);
Next, when you define your particular rest service, specify a type (this is the type of the incoming body:
rest("/")
.put("/A/{subpath1}/{subpath2}")
.type(MyPojo.class)
.to("direct:XYZ");
That's it! The unmarshalling will be magical ;)
Alternatively, you can unmarshal things yourself.
If you'd like to see a working example of the above, check out this program: it has a main() to test it. https://github.com/DariusX/CamelSandbox/blob/master/CamelSandbox/src/main/java/com/zerses/camelsandbox/rest/RestConsumerBindingTest.java

Crossbar.io pass RPC arguments to dynamic authorizer

I am using Crossbars dynamic authorization to authorize all RPCs in my application.
Is it or will it be possible to access the arguments of the RPC in the authorizer?
It might be possible to solve the issue by utilizing "pattern based registrations". The argument can then be moved into the URI to be examined by the authorizer.
For example the protected resource can register com.example.user.*.delete and when the procedure is called with com.example.user.123.delete - the authorizer will be able to extract the user ID from the URI.
This is documented in the WAMP spec and also in the documentation for Crossbar.io
Accessing the arguments of the RPC is not possible. Dynamic authorization is there to work on the level of the data contained in the configuration, not application payload. If you want to do authorization based on the payload, then this needs to be triggered from the side of the callee.

Operation Contract with Different Source or Action Url

Our third party API provides two different web services but have identical methods, models. Nevertheless they only differ on URIs (Web Service Path, Action Path [Operation Contract].
So I have decided to:
Generate the code from their wsdl using VS.
Edit the namespacing to use the same and to be "Common" and not use the service reference instead i use the Reference.cs edited code.
Create a new proxy that will handle the correct URI of the service to use (wrapped the Reference.cs inside of it).
Now, I having an issue with the "Method1", because they have different Action Name. Having an exception of:
"Server did not recognize the value of
HTTP Header SOAPAction:
http://www.api.com/service/Method1"
I just notice that it the correct action name is: http://www.api.com/service1/Method1
The question now is, is there any configuration or behavior that i can use to correct the action name for each method for each service?
Or as long as they keep on adding contracts for each implementation of the API, i should also keep on adding the contracts for each, and just use the ChannelFactory for this?
Please help, thanks.
I ended up directly using the ChannelFactory when faced with the same problem
In my implementation, I had a base interface that had all the common methods to the 2 APIs. Then I had 2 seperate intefaces - one for each 3-rd party API version - that inherits from the base interface and adds methods and [OperationContract] attributes that varied between the two implementations.
When instantianting ChannelFactory<> I used one of the child interfaces. Helped to keep the consumer code clean and maintainable

Ninject Intercept

from what dll can i get the extension of Intercept ?
I've added Ninject.Extensions.Interception from http://github.com/danielmarbach/ninject.extensions.interception
No luck there.
Is there some sample working ?
What I need is to make an interceptor that will path through from WcfClient to WcfServer a different functions with different parameters , that way I wouldn't have to implement already implemented functions behind the WcfServer code.
So the the signature of the function I've already implemented is -
public static T InvokeService<T>(MethodInfo MethodName, Type genericType, Type BlClass, params object[] ParamList)
What it does is activates the Method by BlClass and sends to it the ParamList .
I'd like to make an Interceptor that will dynamically fill the parameters while addressing the WcfServer side .
But first how can I get access to the Intercept extension in my ninjectModule?
Thanks in advance for any help you can provide :)
p.s. Tried out :
using Ninject.Extensions.Interception;
and:
using Ninject.Core;
using Ninject.Core.Interception;
the intercept() Method is within Ninject.Extensions.Interception.Infrastructure.Language.
I had trouble myself to find it.
All of the ninject projects are under http://github.com/ninject
You can find the latest pre-built binaries on our CI server at CodeBetter.com. In order to extend the interception mechanism, you need to reference the Ninject.Extensions.Interception dll and implement the IInterceptor interface or extend the SimpleInterceptor class.
-Ian