I am developing a web service and a client for it. I want to get the client information from the request in the web service's code. For example, I can fetch the client IP from its HTTP request.
Is there any other parameter (like client application name) of a client except IP or client hostname which I can fetch in a web service's code? I can add any configuration in the servers to pass parameters also. I am open all solutions.
Thanks
Thank you for your answer. Actually, i am searching a solution using configurations without any code changing in client side. Solution can be a lower level of OSI or it can be a change in the servers conf. I will apply the solution for a huge system after all. I am just trying with one client and one service now. But actually in the system there are 1500 clients+services. So i don't want to change code in client side.
Related
I have a RESTful web Service that provide function of returning some data whenever a client send GET requests to ask for it:
#GET
#Path("/{deviceId}")
#Produces(MediaType.TEXT_PLAIN)
public String getDataResource(#PathParam("deviceId") long id){
return dataService.getData(id);
}
And the flow for this case would be the client sends request -> the web service returns value. But I want to ask that is it possible that the web service will automatically send response to the client when ever it has new data change inside of it? That means it not need to wait for the client to send request to ask for it. Because I would like to establish a communication between a client and some services running on an Application Server so that the client can always receives the newest data from the Application Server, so I think RESTful web Service can be a solution for it. And in oder to be ensure that the newest data will be transfered to the client side, so the server has to send to the client, not wait for the client to ask for it. Is RESTful web service provides any function like this?
Thank you all!
Is RESTful web service provides any function like this?
No. Not in the context you're asking for.
As answered before, the client could periodically poll for updates on the server. This is usually common option.
Another option - the original server posting updated on the "client". The client then becomes server itself. Viable, if you can expose services on the "client" side.
Maybe what are you looking for are web sockets. It is a long-lasting connection from client, where the server could keep returning data as they come.
There are some books around but you could search the net for more resources depending on the framework you use
You can implement notification system(observer pattern), so that client will poll the server in certain interval and any state change, it can get the result.
You may use the Schedulers to push the data to the client in a certain intervals.
I tried using Muffin's web proxy to record the url's that were hit in the browser.
I am able to track the internet request like google.com,stackoverflow etc.,
But, was unable to track the intranet request like the one which does not need internet. I am not sure how intranet works because those request for the url were not being tracked.
Is there a way to track those request as well(intranet urls).
1) I am able to track the weburls because i am redirecting all the request to the socket i had created in java.But setting it up as a proxy in the settings.
2) Usually intranet sites do not rely on the proxy servers. it will directly communicate though dns server.How to make those request also to go through my socket ?
Note I am trying to achieve it using JAVA sockets.
Use a windows application called FIDDLER.... It can track all type of inbound and outbound connections...
In Java, I am building a stand alone web service client that manipulates records in a cloud based CRM by using its SOAP API. I generated my classes using the wsimport utility with WSDLs that all have addresses prefixed with https in the port binding section of the WSDL. Is Java handling behind the scenes all the wire-level security simply because the address is https? If so, how can I confirm that the SOAP message is being encrypted? My code does work, and I have not needed to worry about security until now, because I am developing in a staging environment with temporary passwords.
Thank you for your help!
Putting https in the URL will almost always do the trick. Even if your code is not capable of https, the webserver at the other end will almost never allow you to talk in HTTP when using the HTTPS port. At least, I've never seen one that does.
It's not a 100% guarantee that you'd bet your business on, but it is close.
If the code you write works on any website that does require https, you are the rest of the way there in terms of assurances.
You can confirm the traffic is encrypted by running a traffic analyzer aka packet sniffer.
I have some Apache CXF Web services published to the Internet, but I want one of them to be only visible to a specific IP through a VPN.
I modified the CXF XML file so that my Web service is only visible when accessing through that IP, but it is already accessible through the net.
How can I publish my Web service to only the IP only visible through the VPN?
Thanks in advance.
IP filtering should ideally not be done on your application layer. Think about it - You need to process the request to find out if your business code should run. You are using application resources for a request that should never have come to the application.
Use a firewall rule to filter the requests instead (Assuming of course that your firewall resides elsewhere). This will reduce the load on your server and centralize the IP filtering rules for a particular group of servers (Application / DB / File etc).
If your service is available on the internet, the rule to block requests via a specific IP do not make sense. You will need to get a list of IPs to white-list if you intend to restrict access by IP for everyone.
For a web service application, I would like for the server to be able to notify the clients about some events. When a client is launched, he calls one of the WS methods to get some information it needs. Then the server, that stores this information, listens continuously for changes on these information and if there is a change, it notifies the concerned client.
I don't know if a web service is a good solution to my problem? I don't know how it may work concerning the TCP connections, since the server may notify a client after a very long time.
What would be the best architecture to solve this kind of issue?
Thanks
EDIT: I've looked at some discussions that propose to use Comet, but if you think there are simpler and more convenient solution, please let me know. Since I'm starting this project from scratch, I have no limitations.
I can also use a polling model where the clients periodically poll the server for the information they need, but then I need to take into account the load that this model may create on the server. I don't know if web services can support such a load when there are a lot of clients.
I've also looked at the asynchronous functionality provided by Servlet 3.0 but I don't know how it may solve my problem.
Without polling: sockets
With polling and webservices: u should use etag (html).
When a client polls he sends a request with an etag. webservice responds either with 200(ok) and data or 304(not modified). 304 has no body => less trafic
Instead of client polling the server, you could implement a callback method on the client so that when ever server want to publish some changes to the client, the server can use the callback method provided by the client.
I can think of one the two approaches below using web services solution:
Callback: When client invokes the server it leaves its call back url and a id, say correlation id. When the server wants to respond back to the client it will just use the call back url to notify. The Server can use a variety of approaches to process the request asynchronously. Your client need not be a webservice for this, but it should be capable of accepting requests (callback). It can be a servlet etc.
Polling: When client makes a request to the server it receives back a id, say requestid. After specified interval client polls the server with this request id to fetch a response. A reasonable timeout and polling interval based on the processing time would be required.