Best Practice for Sending/Receiving XML Files Through Web Methods
|
| Best Practice for Sending/Receiving XML Files Through Web Methods |  Hello,
I am just wondering what is the best practice for sending/receiving XML Files Through a web service method.
For example:
1) As a string _ Public Function SendXml(ByVal xmlString As String)
(But what happens with the xml's encoding then?)
2) As an array of bytes (file representing the Xml)
3)Another way?
Is there any article/paper/help considering this issue?
Thank you very much!
| |  Many thanks for the help!
But what if the structure not fixed or known. For example i want a server to send and receive generic xml files without knowing what's in them beforehand. In that case i can't create a custom class and xmlserialize its attributes.
"Gaurav Vaish (EduJini.IN)" wrote:
> > For example: > > > > 1) As a string > > _ > > Public Function SendXml(ByVal xmlString As String) > > (But what happens with the xml's encoding then?) > > 2) As an array of bytes (file representing the Xml) > > 3)Another way? > > The last option if you have a fixed structure would be the ideal choice. > Look into the topic of XMLSerialization and attributes related to it. That > would give you an idea of how it can be done smartly. > For example: > Public Function Process(ByVal c As Credentials) As UserProfile > ..... > Dim up As UserProfile > .... > Return up > End Function > or > Public Function Exists(ByValue up as UserProfile) as Boolean > Now you want the content of Credentials and UserProfile to be sent as XML > Content. > The advantage in this case is that you don't need to worry about the XML > Encoding. All you need to do is worry about the classes Credentials and > UserProfile -- these are your new / custom classes with XMLSerialization > related attributes applied. > -- > Happy Hacking, > Gaurav Vaish > http://www.mastergaurav.org > http://www.edujini.in > -------------------
| | > But what if the structure not fixed or known. > For example i want a server to send and receive generic xml files without > knowing what's in them beforehand. In that case i can't create a custom > class > and xmlserialize its attributes.
In that case, I normally don't send raw-XML. Technically speaking, it is very much possible to send raw-XML as string (<, > etc get HTML-encoded) My personal choice -- base64 encode the XML. Yes.. it does increase the size of the content by 33%, just a personal preference. Otherwise, even if the data in XML is Unicode data (with characters outside ASCII), it will get UTF-8 encoded for the transfer and you don't need to worry about it. Now as I see your query closely... you are looking at "XML Files" and not "XML Content". In that case, why not try out MIME attachments. That way you can have all attributes related to the file available, specifically the filename as MIME headers itself and don't need to have another parameter (to the WebMethod method) that provides the filename. -- Happy Hacking, Gaurav Vaish http://www.mastergaurav.org http://www.edujini.in -------------------
|
|
|
|
|
 | Members Area | |
|
 | Last Web Marketing |
|
|
|
|
 | Last Programming Tips |
|
|
|
|
 | Last News |
|
|
|
|
|
|