Is there a hook in ServiceStack which will give me access to the serialized service response object and the http response?
Specifically, I want to add a hash of the serialized response object to the http headers which the client will use to verify the content.
An IHasResponseFilter implementation is almost right, but the service response hasn't been serialized and I want to avoid duplicating that work.
Related
As I have a requirement to build a rest service in Message broker to receive the multipart request from mobile apps and just passthrough the request to backoffice system to store the attachments in repository.
And back office system store the attachment and will send the http response to Message broker, then again message will passthrough the response back to mobile apps.
But the request message contentType= 'multipart/form-data' for attachment
and response message contentType= 'application/Json-data' for the status updates back to client system
So is it possible to have a different content type for request for 'multipart' and response 'json-data' for the rest http service?
Thanks.
As long as your REST service accepts and has a handler to process the multipart/form-data then it won't be a problem. Some services for example will ignore a request if it isn't in XML or JSON, others will accept various types of formats.
So check your REST service for what format it can process.
As for the response, again, if the client has a header stating it accepts JSON, then you can send it JSON. This is more easier to check as the REST service can check the "Accept" header on the request to determine if the client is happy to receive JSON.
Many REST services check this to send commonly either JSON or XML back.
So to summarise, yes you can mix and match request/response types as long as both the client and service are happy to accept and handle the request/response types.
I want to create a rest service, which should retrieve all the available HTTP POST parameters in the request, note that the parameters are dynamic hence I can't use FormParam.
I made the rest service to consume form url encoded and got access to HttpServletRequest object using org.apache.cxf.jaxrs.ext.MessageContext.getHttpServletRequest(), but I can't find any parameters in the request.
Any idea how to retrieve all the http post parameters available in the httpservletrequest object in rest server ?
Thanks
okay I just had to have MultivaluedMap as the argument for my rest service, this map will have all the http post parameters in it.
From a wcf4 service need to access to the underlying http request,including it's soap message, how can I do that from code?, I know I can use fiddler, etc, but need to do it programatically.
Look at Message Inspectors.
I'm implementing a REST service using WCF which will be used to upload very large files. The HTTP headers in this request will communicate information which will be validated prior to allowing the upload to proceed (things like permissions, available disk space, etc). It's possible this validation will fail resulting in an error response. I'd like to do this validation prior to the client sending the body of the request, so it has a chance to detect failure before uploading potentially gigabytes of data.
RESTful web services use the HTTP 1.1 Expect: 100-continue in the request to implement this. For example Amazon S3's REST API can validate your key and ACLs in response to an object PUT operation, returning 100 Continue if all is well, indicating you may proceed to send your data.
I've rummaged around the WCF documentation and I just can't see a way to accomplish this without doing some pretty low-level hooking into the HTTP request processing pipeline. How would you suggest I solve this problem?
I have a WCF service which would like to support basicHttpBinding and webHttpBinding. When the client successfully login, server will generate a token for client to pass to server on all the request make later. Question is how the client can pass the token to server? I don't want to add an extra parameter on every web method to hold the token.
Typically, the best way to do something like this is passing such "meta-information" in a WCF header. You can easily create a message inspector to extend WCF (it's really not that scary and hard to do!) which would inject the token into every outgoing request from the client, and retrieve it from the header and validate it on the server side.
There are a number of pretty good blog post out there showing you how to create a message inspector:
Richard Hallgren's WCF postings
Writing a WCF message inspector
Automatic Culture Flowing with WCF by using Custom Behaviour
Check out the two relevant interfaces to implement:
IClientMessageInspector on the client side, which has a BeforeSendRequest and AfterReceiveReply message to implement
IDispatchMessageInspector on the server side, which has a AfterReceiveRequest and BeforeSendReply method to implement