views:

82

answers:

3

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 this way?

+1  A: 

Yes, you can send XML when calling a REST webservice, but you have to use the POST method instead of GET.

Alejandro Martin
I actually use the POST method :)
Ravi
Then you already got it. Just build the xml string in the client with all the parameters needed and send it to the correct server endpoint.If you are using some kind of entity to store the values in the server, and you need an example of how to build the string, you can create a method in the server with no input parameters that returns a instance of this entity. In the response xml you will get an example of what you have to build in the client.
Alejandro Martin
Thanks but I tried posting using XML but it doesn't seem possible at the moment
Ravi
A: 

Yes, go for it! Or use JSON, or YAML, or TAB-delimited text, or whatever strikes your fancy.

Adam
Yes JSON could be a good idea since it is readable...Ill try to find how to form a JSON object out of several parameters since i have to create and extract data from one.. Do you have a sample with you pal?
Ravi
Check out JavascriptSerializerClass and DataContractJsonSerializer [1] http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx [2] http://msdn.microsoft.com/en-us/library/system.runtime.serialization.json.datacontractjsonserializer.aspx - HTH
Adam
+1  A: 

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.

jbrendel