Passing parameters in REST? can I only pass strings or xml is allowed?
I have a customer table which consists of almost a 50++ fields. I was just thinking if would it be feasible if I pass these through a XML formatted text since their are a lot of parameters
Sample Below:
[OperationContract] [WebInvoke(UriTemplate = "new/customerxml/", Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat= WebMessageFormat.Xml)] public XmlElement NewCustomer(XmlElement value)
Do i pass the XmlElement t开发者_如何学运维his way?
Yes, you can send XML when calling a REST webservice, but you have to use the POST method instead of GET.
The way in which you pass data is completely up to you. You are free to use your own, proprietary binary format if you are so inclined. Not many clients may know what to do with that, but if you are using your own client code...
It would be good to define a content type and use that. Maybe use ordinary application/xml for clients that don't know your proprietary format and application/foobar for your own special 'foobar' content type.
Yes, go for it! Or use JSON, or YAML, or TAB-delimited text, or whatever strikes your fancy.
精彩评论