In java i have created a JAX- web service, which is up and running, my client connects to the web service.
if web service is up, it works fine. but if my web service is not
up, it should show some message to the client about that issue.
in java how can i implement this functionality.
My server should show a proper message on client side.
If the web service is not up, it cannot provide any functionality. The client will probably recieve an HTTP error (like 404 - not found or 500 - Internal server error) or a timeout.
To display a useful message to the end user you would need to create a client application through which your web service is accessed. The client application could display appropriate messages in case the service could not be reached. An example of creating a simple JAX-WS client can be found here.
If the service is up, but cannot handle the request, then you could provide a meaningful error in the response by throwing a GenericSoapFault with the error message as argument.
Related
I'm trying to configure the WSO2 API Manager. (version - v4.0.0)
When I try to create REST API and point to the endpoints I"m getting a Connection error message for the given endpoints. I have hosted the API Manager and the back end services on the same server(backend services are running on the tomcat application on the same server in port 8080)
API Manager Log produces the following message :
ERROR {org.wso2.carbon.apimgt.rest.api.publisher.v1.impl.ApisApiServiceImpl} - Error occurred while sending the HEAD request to the given endpoint url: org.apache.commons.httpclient.ConnectTimeoutException: The host did not accept the connection within timeout of 4000 ms
would really like to what has caused the issue.
P.S: I can access the backend services directly without any connection issues using a REST client.
It's difficult to answer the question without knowing the exact details of your deployment and the backend. But let me try. Here is what I think is happening. As you can clearly see, the error is a connection timeout The host did not accept the connection within timeout of 4000 ms.
Let me explain what happens when you click on the Check Endpoint Status button. When you click on the Check Endpoint Status button, the Browser is not directly sending a request to the Backend to validate it. The Backend URL will be passed to the APIM Server, and the Server will perform the validation by sending an HTTP HEAD request to the BE service.
So there can be two causes. First may be your backend doesn't know how to handle a HEAD request which is preventing it from accepting the request. But given the error indicated it's a network issue, I doubt it even reached the BE.
The second one is, that your Backend is not accessible from the place API Manager is running. If you are running API Manager on Server A and trying to access API Manager via browser from Server B(Local Machine). Although you can access the BE from Server B may be from Server A it's not accessible. When I say BE is not accessible from API Manager server, it means it's not accessible with the same URL that was used in API Manager. It doesn't really matter if it runs in the same Server if you are using a different DNS other than localhost to access it. So go to the server API Manager is running and send a request using the same URL that was used in API Manager and see whether it's accessible from there.
First try doing a curl request by login into the server where APIM is running (not from your local machine). Maybe due to some firewall rules within the server, the hostname given in the URL may not be accessible. Also, try sending a HEAD request as well. You might be able to get some idea why this is happening
Currently I discover micronauts and regarding websockets, I am looking for a solution. Let me describe the idea and the issue:
A Browser connects to a microservice with a websocket endpoint
A session-ID may be send to the websocket endpoint to identify the client
On a different http request a long term async work has been started (e.g. with a message queue)
The process finishes and needs to tell the right websocket endpoint-thread to give this update to the browser.
But what would be a good way to tell the correct websocket thread, connected to the browser, an update is available?
What if there are more than one websocket microservices, called by a balancer? I think then they can not share any "Session" with an http server?
Can the exact websocket endpoint subscribe to a message service like Kafka?
I just found people asking the same with no answer. But it seems to be a typical issue.
Quoting Java Servlet API Spec : "A client (e.g., a Web browser) accesses a Web server and makes an HTTP request.This request is received by the Web server and handed off to the servlet container."
Can anyone elaborate on how exactly this control is passed( from Web server to Servlet Container)?Does it use HTTP connectors of some kind like Apache Coyote?
The implementation detail depends on server-to-server. Http Connector architecture is what used by Apache Tomcat internally.
Web server is nothing but a Java application which opens socket on a port and keeps listening on that port over HTTP protocol + Some other facilities. These some other facilities consist of things like components lifecycle management etc.
Basic task of a web server is to listen for requests on a port number over http protocol and then respond to that. So in most common server available today they keep polling on port 80 over http protocol. When you send some http request on port 80 to the host where the program is listening then program listening responds to that. Now on receiving the request the server program (which is listening on port 80 here) will get a new thread from its thread pool and in that thread will call a servlet's service method (a servlet instance will be created if its the first request see here for more details).
ADDITION:
Web Server is a machine that has a HTTPD service running. When you send the request to server the server intercepts that.Web server is responsible for receiving request and generating response. Now the server gets the input stream on the socket where it was listening. From here it delegates the input to servlet container by wrapping it in a new thread (so that things get processed asynchronously and web server can process other http requests when the previous request is served in a separate thread by servlet). A Servlet Container is a part of a Web Server. A Servlet Container is a separate module; it may run within the web server as a single standalone program (tomcat is one example of it). Now servlet container instantiate a new servlet if not already there and calls its service method in a new child thread. Servlet container wraps the http request in HTTPRequest object and pass it in one of the parameters to service method.
If you're in the case of a apache + tomcat architecture for example, there is a protocol for the connectors (AJP). Have a look at mod_jk and mod_proxy.
When both components (web server and container) are in the same software (tomcat can manage direct http requests), I don't know of the inside implementation. (It was never useful for me, in fact. At the contrary, AJP connectors are commonly used)
I am going to write a smart client application. This application will be swing based desktop client that will communicate with web service. I want to be a message has been sent to client from web service when any change occurs at server side file system. I wanted to use web services but I am not sure how I would implement a two-way communication between the server and client. Is it possible? If so how? If not what are the alternatives?
You have to program your client to be able to ping a request after a predefined frequency to check if there is a changes occurred on the server side. The client expect the changes occurred on the server or null if no change.
I'm running two instances of tomcat on the same machine for 2 parts of a web application(client app and server app). the client has no datastore and uses the server to interact with the database. The server app uses a wsdl web service to listen for GET requests from the client. I get an invalid login everytime I try to login through the client app. If I try to access the LoginService via browser directly I get this error from the catalina logs.
[PhaseInterceptorChain:369] Interceptor for {http://ws.myoscar_server.oscarehr.org/}LoginWsService has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: No such operation: (HTTP GET PATH_INFO: /myoscar_server/LoginService)
I'm not sure what you mean by "everytime i try to login." I think the error you see in the catalina logs is just saying that you are hitting the web service that is listening for only POST requests, but with a browser, you are sending a GET request. That error might be throwing you off. I would first use something like Firefox Poster to send a POST request to your service and see what the real error is.