473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
<WebMethod()> _
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!

May 23 '06 #1
3 1984
> For example:

1) As a string
<WebMethod()> _
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:
<WebMethod()> Public Function Process(ByVal c As Credentials) As UserProfile
.....
Dim up As UserProfile
....
Return up
End Function

or

<WebMethod()> Public Function Exists(ByValue up as UserProfile) as Boolean
....
End Function
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
-------------------
May 25 '06 #2

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
<WebMethod()> _
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:
<WebMethod()> Public Function Process(ByVal c As Credentials) As UserProfile
.....
Dim up As UserProfile
....
Return up
End Function

or

<WebMethod()> Public Function Exists(ByValue up as UserProfile) as Boolean
....
End Function
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
-------------------

May 25 '06 #3
> 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
-------------------
May 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

131
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately...
20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
by: Przemo | last post by:
Hi, I want to send messages from one application to another, working on 2 different computers in a no-domain enviroment using private queues. Am I to place queue on the source or on the...
9
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim...
12
by: MrQuan | last post by:
G'day all, I have a requirement to communicate between two or more PCs over the Internet, however I have no idea how to go about this. I'm not talking about a chat programme as such, I want to...
2
yashg
by: yashg | last post by:
I am building a data backup application in C# using Sockets. It has a server component and a client component. The client is going to upload files to the server through TCP sockets. I've got all...
9
by: =?Utf-8?B?QW1tZXI=?= | last post by:
I've read many incomplete opinions about the "Best Practice" for securely accessing SQL but what I really need to find the "Best Practice" that fits my applications needs. Currently (alpha...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.