How to call Async Web service in Java - java

I thought there would be lot more info/tutorials on this one, but some how I'm not able to figure out how to call an async SOAP web service using Java. The web service in question may not necessarily be a Java web service. I only have access to web service's run time WSDL.
Any pointers will be greatly helpful.
Also would it be possible to dynamically call such a web service? The Dynamic Invocation Interface method javax.xml.rpc.Call allows that for sync calls, but haven't found anything on async calls.

See the JAX-WS standard for the use of Future objects to communicate, asynchronously, with services. For some examples see CXF documentation on JAX-WS clients.

It is possible to do an asynchronous web service invocation, so that the client is not blocked waiting for the response. Check this link text

Related

Is using akka with a rest service pointless in this scenario?

I'm exposing functionality to access user details via a rest call.
From reading this post: Is Spring Boot MVC controller multithreaded? spring boot rest services are multithreaded. Does this mean using Akka to multi-thread web services does not serve any use?
Using Java Akka will not offer any multi-threaded advantages but will offer:
If a rest call fails with error (e.g 404) Akka can be used to restart the rest call or kill the thread, so stopping the service.
If the a certain rest call is taking much of time to complete Akka can be used to kill the call after a duration of time.
Akka can be used to throttle requests to rest client, useful if service allows max requests in period of time.
Are my assertions correct? If I'm not concerned with these points above, should I still use Akka or use the functionality to access the user details and not wrap the it with Akka? Could Java futures be also used for these points?

How to identify whether a web service is asynchronous or synchronous

I know that there are two types of web services called asynchronous web services and synchronous web services. What I want to know are
1.
Can I identify whether a web service is asynchronous or synchronous by inspecting the WSDL of the service? Or is there any other way such as inspecting the generated stub etc?
2.
Can I develop an asynchronous client for a synchronous web service? Does it make sense?
Thank you.
I'm not an expert, but I'll give my two cents and hope that you find this useful.
Well I assume that it depends. You can have an asynchronous architecture with no signs of it. Someone could implement the following
The client makes a request to the service.
The service responds with a success or error message just to indicate the status of the request.
The service begins to process the request.
The service makes a request to another endpoint. This request is the actual response for the first request.
The service get a response, that the message was received successfully.
This is an asynchronous architecture. The service (actual service) when finished sends the actual response to an endpoint. This endpoint is actually the client that sent the first request.
This endpoint, the one that the client is listening to, for the actual response can be predefined (hard coded), or can be included as a parameter (callback) in the first response. If the case is the latter, then I guess you could deduce that this is an asynchronous web service.
For the second part of your question. Yes you can. Check this Asynchronous web services calls with JAX-WS: Use wsimport support for asynchrony or roll my own? and this http://cxf.apache.org/docs/asynchronous-client-http-transport.html

Forwarding requests from one web service to another

So the case is the following:
I have an application that communicates with a JAX-RPC web service (Hosted in an .ear package on a JBoss server). We had a requirement of moving all the operations in this web service to a new one with a new name, keeping in mind that we should keep our backward compatibility with clients with the old web service stub. The idea is that I shouldn't keep the logic of the operations in both web services, and instead, try to forward the requests for older clients from the old web service to the new one. I found a solution, but I don't know what are its downsides: I kept the skeleton of the operations in the old web service, and in my ejbCreate(), I created an instance of the bean of the new web service, and now all I do is invoking the operations of the new web service using this bean instance (passing the same arguments as received from the client without running any logic). Is my solution valid? Are there any better alternatives?
why not to use ws-addressing? did you read about it ? (honestly I never used it, but I know it can be used to proxy requests)
Old thread, but here is a better answer for fellow googlers:
Check out membrane-soa reverse proxy: http://www.membrane-soa.org/reverse-soap-proxy.htm
To solve the exact problem in question check this doc: http://www.membrane-soa.org/service-proxy-doc/4.0/soap-quickstart.htm

GWT - Invoke the default 'greetServer' web service from a browser

I'm absolutely new to GWT, java and eclipse, but I'm an experienced MS programmer.
I installed eclipse and GWT and created a default project (called it test2) with pre-built sample gwt code. It comes with one java web service on the backend called 'GreetingService' which has a single web method called 'greetServer' that takes a single parameter called 'input'. I tried to invoke it in the web browser with many different combinations, but with no success (my project name is called 'test2):
http://127.0.0.1:8888/test2/greetServer?input=hello
http://127.0.0.1:8888/greetServer?input=hello
http://127.0.0.1:8888/test2/greetingService/greetServer?input=hello
http://127.0.0.1:8888/test2/greetingService?input=hello
etc
but I get http error 404 not found.
My question is, how can I invoke the web service from a browser and see the return data? I know this can be done easily with WCF or asmx web services but I'm not familiar with java web services.
Thanks a bunch!
The GWT Remote Service Servlet only uses HTTP Post. If you want to see the data (which will be encoded by gwt anyway) use could use firebug and take a look at the traffic.
The greeting service isn't intended to be a web service. It's a demo of GWT's remote procedure call (RPC) facility over AJAX. As with most RPC frameworks, the server side is only intended to be called from the generated client stub.

Best way for handle Read HTTPRequst post data on Restful api

What is the best way of save data using Restful web service without using Ajax? As a example I need to add a new Customer to the database using submit button.
What is the best way of transfer data format (text,json,xml) ?
How to read POST or GET data from HttpRequest object?
If you can please give me a example in java .
Thank you
I think you need to separate the concepts a bit. A "Restful Web Service" is a web service designed using REST principals, whereas AJAX is a set of technologies used often on the client side for asynchronous requests to multiple resources (without fully reloading the page). The web service really shouldn't care how the HTTP request is generated, just the contents of the HTTP request.
Now if you're concerned about writing a rest service in Java, I would highly recommend looking into JAX-RS and the reference implementation Jersey. There are lots of examples of how to get up and running. You can use MessageBodyReader implementations are to convert data from the HTTP request entity into Java objects.
Obviously this is not the only way to get started with writing a Restful web service in Java, but is one way.
It's very definitely worth your time to carefully study Richardson and Ruby's RESTful Web Services to learn the REST architectural style. In addition to #ach_l's recommendation to use Jersey, take a look at the Restlet Java framework, which is completely wonderful.

Categories