Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2005

Tip: Looking for answers? Try searching our database.

DataSet Vs Xml string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Modica82 - 09 Feb 2005 09:51 GMT
Hi All,

I am very new to web services, so am struggling to understand exactly what I
am doing with regards to its returns etc.  I have been given the task of
designing and developing a web service which will allow external companies,
access to our information.  The problem for me is that these companies will
be using different platforms from which to consume our web service.  My
question is what I should use as the return type for more complex data
structures.  Should I use the intrinsic dataset object and return that,
should I create a typed dataset as then a definitive XML Schema will be
produced, or should I just build and XML string from the information I return
from the database and send that back across.

I know that all the return types are serialized into XML, but does this mean
that they can be accessed when they get to other end??  I would really
appreciate some input here, if anyone can help me understand this that would
be great!

Thanks,

Rob
erymuzuan - 09 Feb 2005 09:57 GMT
Take alook at Christian Weyer WS-Contract first, it's good tool for you
to get started in designing web services. Remember services rely on
schema as a contract not type.

BTW, avoid ADO.Net dataset at all cost. It will not work since dataset
is a strongly related to .Net.

regards
erymuzuan mustapa

> Hi All,
>
[quoted text clipped - 17 lines]
>
> Rob
Modica82 - 09 Feb 2005 10:33 GMT
Hi Erymuzuan,

Does this mean i should generate my own XML to send back, again i have not
done loads of XML so this will take some doing, would it be best to send the
XML back with a schema, or just send the XML down the wire as a string?

Rob

> Take alook at Christian Weyer WS-Contract first, it's good tool for you
> to get started in designing web services. Remember services rely on
[quoted text clipped - 27 lines]
> >
> > Rob
erymuzuan - 09 Feb 2005 14:57 GMT
Not necessarily, the best practive is to design the XML schema for your
web services interface. the use the tool to generate server's web
services stub. or you can use xsd.exe to generate .Net types from your
XML Schema

regards
erymuzuan mustapa

> Hi Erymuzuan,
>
[quoted text clipped - 35 lines]
>>>
>>>Rob
SQLScott - 09 Feb 2005 14:25 GMT
Rob,

In my opinion you should build and return an XML string.  In fact, the best
way to do it is to build your xml string and return it as a byte array for
quick performance.  Let me know if you'd like a code sample.  I have build
several Web Services this way.  In fact, I had questions such as yours and I
went straight to Francesco Balena (if you know who he is) and this method was
highly recommended.

This way any company or customer can read it and you are not tied to any
platform or language, that is the beauty of XML.

HOpe this helps.

Scott

> Hi All,
>
[quoted text clipped - 17 lines]
>
> Rob
Modica82 - 09 Feb 2005 14:59 GMT
Hi Scott,

I was planning on using the XMLTextWriter class to create XML on the fly and
return it as a string.  I have read alot about XML but never really used it
commercially, so i want to get it write (also i have only been at this job a
month and trying to impress :)) Some code samles would be great if you could
send them.

Thanks in Advance,

Rob

> Rob,
>
[quoted text clipped - 33 lines]
> >
> > Rob
SQLScott - 09 Feb 2005 15:15 GMT
Ask and ye shall receive.  

Web Service Code:
<WebMethod()> _
Public Function GetData() As Byte()
   Dim ms As MemoryStream
   Dim xmlms() As Byte

   ms = New MemoryStream

  'code to get data goes here

   'Now create your xml doc
    xtw.Formatting = Formatting.Indented
    xtw.Indentation = 2

    xtw.QuoteChar = """"c

    xtw.WriteStartDocument(True)

    xtw.WriteComment("Data from db")

    xtw.WriteStartElement("Data")

    xtw.WriteStartElement("Employee")

   Dim xtw As New Xml.XmlTextWriter(ms, System.Text.Encoding.UTF8)

   xtw.WriteElementString("FirstName", "Evel")
   xtw.WriteElementString("LastName", "Knievel")

   xtw.WriteEndElement() 'closes the data node
   xtw.WriteEndElement() 'closes the employee node

   xtw.WriteEndDocument()

   xtw.Flush()
   xmlms = ms.ToArray

   ms.Close()
   xtw.Close()

   Return xmlms

End Function

Hope this help!

Scott

> Hi Scott,
>
[quoted text clipped - 45 lines]
> > >
> > > Rob
Modica82 - 09 Feb 2005 15:23 GMT
Thanks Scott,

Has given me some ideas

Rob

> Ask and ye shall receive.  
>
[quoted text clipped - 95 lines]
> > > >
> > > > Rob
SQLScott - 09 Feb 2005 15:29 GMT
OK, let me know if you have any question.  

There is a copy/paste error in the code below.  The "Dim xtw As New
Xml.XmlTextWriter(ms, System.Text.Encoding.UTF8)" statement should go with
the rest of the other Dim statements.

Sorry about that.

Scott

> Thanks Scott,
>
[quoted text clipped - 101 lines]
> > > > >
> > > > > Rob
Modica82 - 09 Feb 2005 15:59 GMT
Thanks again Scott,

I do have a quick question, but you may or may not have the answer, have you
ever created any sort of schema(xsd) to be passed back with your XML, if so
how did you do it?

Thanks in advance,

Rob

> Hi Scott,
>
[quoted text clipped - 45 lines]
> > >
> > > Rob
SQLScott - 09 Feb 2005 16:09 GMT
Unfortunately, I have not.  But i can point you to some great references on
XSD schemas if you want them.

Scott

> Thanks again Scott,
>
[quoted text clipped - 55 lines]
> > > >
> > > > Rob
Modica82 - 09 Feb 2005 16:19 GMT
That would great.  I think i was being a bit dim before, you can reference
the schema from anywhere, so as long as it is accessible on the web, you can
point you XML to use it, not sure how well that works for web services, but i
am sure i will find out soon enough.

Cheers!

Rob

> Unfortunately, I have not.  But i can point you to some great references on
> XSD schemas if you want them.
[quoted text clipped - 60 lines]
> > > > >
> > > > > Rob
Dev - 21 Feb 2005 12:03 GMT
if you are getting data from DataSet then dataset itself represent all data
in xml... n prob . u dont need to write your own parser

> That would great.  I think i was being a bit dim before, you can reference
> the schema from anywhere, so as long as it is accessible on the web, you can
[quoted text clipped - 69 lines]
> > > > > >
> > > > > > Rob
Modica82 - 21 Feb 2005 14:23 GMT
Hi Dev,

I know that the DataSet can pump out XML based on the data contained within
it, the problem with it is that it creates elements with names that are not
always particularly descriptive for third parties.  We wanted a bit more
control over the XML so i am choosing to write it myself, that way we know
what we are sending across and can document the web service to tell third
parties what to expect, safe in the knowledge that they are recieving what we
intended to send them as set out in our documentation.

Regards,

Rob

> That would great.  I think i was being a bit dim before, you can reference
> the schema from anywhere, so as long as it is accessible on the web, you can
[quoted text clipped - 69 lines]
> > > > > >
> > > > > > Rob
Daniel - 25 Feb 2005 14:54 GMT
Scott - Tried your code and it worked but when I call the HelloWorld function
from Cold Fusion I'm not getting data, just alot of numbers.  I like this
idea and seems easy but how does the end user (consumer) see the correct data?

> Hi Dev,
>
[quoted text clipped - 83 lines]
> > > > > > >
> > > > > > > Rob
Modica82 - 25 Feb 2005 15:11 GMT
Hi Daniel,

What you are returning is an array of bytes that represent the file, what
you need to do is using the cold fusion file system objects (Not sure what
they are) and generate a file using the byte array provided.  I am sorry if
this is a bit vague but i know nothing about cold fusion.

Regards,

Rob

> Scott - Tried your code and it worked but when I call the HelloWorld function
> from Cold Fusion I'm not getting data, just alot of numbers.  I like this
[quoted text clipped - 87 lines]
> > > > > > > >
> > > > > > > > Rob
Daniel - 25 Feb 2005 15:54 GMT
Modica - Have you successfully created any webservices that are being access
by non microsoft consumers?  I've been following this post  and would like to
see what others have done.

thanks.

> Hi Daniel,
>
[quoted text clipped - 98 lines]
> > > > > > > > >
> > > > > > > > > Rob
Modica82 - 25 Feb 2005 16:05 GMT
Hi Daniel,

I am in the process of designing a web service wich will have to have a very
high level of interopability becuase it is going to be used on a cobol site
for starters.  I have not implemented it so i cant vouch if my approach is
the best, but what i have done is different to the approach i started out
with here.  What i am doing is desiging my messages (request and response) as
XML Schemas (XSD files) which i will then go onto generate my WDSL file from,
the link for the article i used is below.  So instead of using XML as
strings, which actually get serialized differently to say an XML document,
which actually gets serialized as XML, i am going to pass back XML with
classes that will be generated from my Schema.  I hope that makes sense.

http://msdn.microsoft.com/msdnmag/issues/02/12/WebServicesDesign/

Hope that helps,

Rob

> Modica - Have you successfully created any webservices that are being access
> by non microsoft consumers?  I've been following this post  and would like to
[quoted text clipped - 104 lines]
> > > > > > > > > >
> > > > > > > > > > Rob

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.