Abort creation if reply to client failed in restful webservice - web-services

I'm trying to create restful microservice.
So I have a client service and server service.
Client service wants to create and update some entitites via http with rest. And the server provides the service for that.
The client have a persitent state. Part of that state is entities that he created. So he need to store 'ids' of entities that server created for him.
One problem that I'm thinking about is what to do when client failed when server was executing create operation. So client executes /entities/ POST
Server gets the request and replies with {id = n, ...}, but client already dead.
So now client can't restore it's state after fail.
I know of course that I can do that without using http with persistent message queue and request-reply pattern (via rabbitmq or something else) but I really wan't to create a restful service.
PS And of course It can be achieved with storing storing client state on server one way or another. Like using some link to client in entity.

Related

server method to unsubscribe clients

Is there a method, which can be used by a server to destroy a client?
currently, only the client can unsubscribe/unregister from the WAMP server by itself. however, if the client crashes, the subscribe id stays occupied by a dead client. hence, we need to change the subscribe id manually and restart the client, which is not feasible in a productive environment.

RPC Authentication

I'm working on communicating data on local machine using Remote Procedure Calls ( RPC ). My requirement is use RPC to communicate data between two processed, but server should authenticate client by some means.
I came across RpcBindingSetAuthInfo which set authentication and authorization information. The fourth parameter is authentication service which can be anything from http://msdn.microsoft.com/en-us/library/windows/desktop/aa373556(v=vs.85).aspx
WINNT authentication is not applicable in my case since client does not run under any particular user. Looking at the documentation, I don't understand which authentication service would be applicable in my case. I need some way to authenticate the client based on some token etc. It would be great if someone could shed some light/ give some pointers of RPC authentication.
Thanks,
Yes token generation is what we use in our product as well . For e.g when the client requests to connect to the server , after authentication the server generates a unique id which it sends to the client . Now the client creates an instance of the server interface and which returns a pointer on which all the further communication can take place . When the client disconnects , the server unregisters or removes the unique id from its list of client's connected

Response from Web Server is dependent on ZeroMQ (0MQ) RES

In lightweight SOAs I've seen many designs that have a Web Server receives Client requests and send responses that are dependent upon responses from other services. I've also seen this done incorrectly resulting in unacceptable latency issues.
For Example:
Assume:
We have 1 Web API Server and 1 Service A API.
Web Server performs basic User Auth and other User functionality.
Service A performs database operations.
ZeroMQ (ZMQ, 0MQ, etc) REQ/RES user for service messaging
Work Flow:
Client makes request to Web API Server API.
Web Server performs database operations (auth etc).
Web Server makes request to Service A API.
Service A performs database operations.
Service A responds with data to Web Server.
Web Server receives response and sends response to client.
This pattern is different from the typical offline message queue processing work flow. As well it includes a request to a single service (A)
While trying to maintain separate system services is this a correct usage pattern with ZeroMQ?
I'm trying to figure out if ZeroMQ can be used to make service requests and send the results to client web service requests without significant performance issues.

What does it mean when a web service is asynchronous?

What does it mean when a web service is asynchronous? Is this only used when you call it with Ajax and you have a part on your page that refreshes when the web service is done? Thank you.
I know this is an old topic, but whether a web service is synchronous or asynchronous depends on the design of the web service and has nothing to do with Ajax. An asynchronous web service transaction proceeds like this:
The client calls the web service. In the call the client sends a callback end point implemented as a service by the client.
The web service returns a "message received" reply.
...
(Some other processing occurs)
...
The web service completes its task, then calls the callback endpoint provided by the client.
The client callback replies with message received.
See Developing Asynchronous Web Services or How to: Create Asynchronous Web Service Methods
The question is whether it's the web service that's asynchronous, or your access to it. In the context of a web page, it's more likely that the service is synchronous, but that it is being accessed asynchronously.
Most likely, the service is being called via AJAX. The call is made to the service, and the page then continues. When the response comes in, either the success or the failure functions are executed, asynchronously.
Synchronous means that you call a web service (or function or whatever) and wait until it returns - all other code execution and user interaction is stopped until the call returns. Asynchronous means that you do not halt all other operations while waiting for the web service call to return. Other code executes and/or the user can continue to interact with the page (or program UI).
So, I would not say that the web service itself is asynchronous, I would say that your ajax call to the service is asynchronous.
When you call synchronous web service the service processes the request and return HTTP status code 200 OK (1) if everything went as expected, or error 4xx. The call is blocked while processing and the request and can take significant time.
When web service is asynchronous the main difference is that call should return instantly with HTTP 202 ACCEPTED (2) which means that request is taken in queue but not processed yet.
(1) 200 OK http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1
(2) 202 ACCEPTED http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3
An asynchronous web service allows a client to submit a request, process the request and respond to the client after a given time -- the client would not block all activity on receiving a response.
Comparatively, a web service that is synchronous would provide a client directly with a response, expecting the client to block all activity until a response is returned. In this case the web service would limit the client to process requests one at a time.

where to publish web service?

Where we need to deploy or publish wsdl so that consumer can get the service?
On a Web Server that the consumer is able to access.
If you're not ready to publish anything to the server yet, you could also simply send them the WSDL file (via email, etc.) so they can start developing against it without having the services ready to be called.