Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Return XML Document

Reply
Thread Tools

Return XML Document

 
 
Anthony Bollinger
Guest
Posts: n/a
 
      07-25-2008
This is my first attempt at writing an XML web service.

I have a query successfully written for SQL Server that returns XML data
using FOR XML AUTO. It seems rather than processing the XML and building a
text string in XML format to return, there should be some way to directly
return the XML I get from SQL Server. What I seem to be getting is a
properly formatted XML string that is not identified as XML (not sure why),
but I want this to work pretty much like an RSS feed. I don't know how those
are generated, but whatever requests them knows what to do with them. What I
return should also be recognizable as an XML document. What is the best way
to do this?

Thanks!
Tony

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      07-26-2008
I do not have an answer right this second, as it has been awhile, but the
answer is located in books online.

By default, you get an XML snippet from the FOR XML features in SQL Server.
There is either a flag that returns a proper root or an easy way to get it
to return. Then you will have valid XML.

If I get the chance, I will post, but take a look at the SQL books online
FOR XML documentation and you should find the answer.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"Anthony Bollinger" <> wrote in message
news:%239C2%23$...
> This is my first attempt at writing an XML web service.
>
> I have a query successfully written for SQL Server that returns XML data
> using FOR XML AUTO. It seems rather than processing the XML and building a
> text string in XML format to return, there should be some way to directly
> return the XML I get from SQL Server. What I seem to be getting is a
> properly formatted XML string that is not identified as XML (not sure
> why), but I want this to work pretty much like an RSS feed. I don't know
> how those are generated, but whatever requests them knows what to do with
> them. What I return should also be recognizable as an XML document. What
> is the best way to do this?
>
> Thanks!
> Tony


 
Reply With Quote
 
 
 
 
Gaurav Vaish \(a.k.a. MasterGaurav\)
Guest
Posts: n/a
 
      07-27-2008
> properly formatted XML string that is not identified as XML (not sure
> why), but I want this to work pretty much like an RSS feed. I don't know
> how those



I think the reason is that the XML string does not have a root.

You can use:

SELECT * FROM TableName FOR XML RAW('NameOfRootElement')


HTH

--
Happy Hacking,
Gaurav Vaish | http://dwt.sourceforge.net
http://blogs.mastergaurav.com | http://eduzine.edujini-labs.com
--------------------------------




 
Reply With Quote
 
Gaurav Vaish \(a.k.a. MasterGaurav\)
Guest
Posts: n/a
 
      07-27-2008
> properly formatted XML string that is not identified as XML (not sure
> why), but I want this to work pretty much like an RSS feed. I don't know
> how those



I think the reason is that the XML string does not have a root.

You can use:

SELECT * FROM TableName FOR XML RAW('NameOfRootElement')


HTH

--
Happy Hacking,
Gaurav Vaish | http://dwt.sourceforge.net
http://blogs.mastergaurav.com | http://eduzine.edujini-labs.com
--------------------------------




 
Reply With Quote
 
Anthony Bollinger
Guest
Posts: n/a
 
      07-27-2008
Thank you for your answer. I am not sure which SQL books online you mean.
Could you post a URL or two?

I do not think the issue I am having is proper XML, since I have that, but
rather it is not identified on the receiving end as XML, even though the
returned file is properly formatted. In fact, my first line is:

<?xml version="1.0" encoding="utf-8" ?>

And the remainder is a full XML document.

Unfortunately, I must need to set something additional in the web service
response, because consumers are not recognizing this as an XML file. Is
there a way to set the type of the response? I think I have seen this.

Many thanks! --Tony

"Cowboy (Gregory A. Beamer)" <> wrote in
message news:%...
>I do not have an answer right this second, as it has been awhile, but the
>answer is located in books online.
>
> By default, you get an XML snippet from the FOR XML features in SQL
> Server. There is either a flag that returns a proper root or an easy way
> to get it to return. Then you will have valid XML.
>
> If I get the chance, I will post, but take a look at the SQL books online
> FOR XML documentation and you should find the answer.
>
> --
> Gregory A. Beamer
> MVP, MCP: +I, SE, SD, DBA
>
> Subscribe to my blog
> http://gregorybeamer.spaces.live.com/lists/feed.rss
>
> or just read it:
> http://gregorybeamer.spaces.live.com/
>
> ********************************************
> | Think outside the box! |
> ********************************************
> "Anthony Bollinger" <> wrote in message
> news:%239C2%23$...
>> This is my first attempt at writing an XML web service.
>>
>> I have a query successfully written for SQL Server that returns XML data
>> using FOR XML AUTO. It seems rather than processing the XML and building
>> a text string in XML format to return, there should be some way to
>> directly return the XML I get from SQL Server. What I seem to be getting
>> is a properly formatted XML string that is not identified as XML (not
>> sure why), but I want this to work pretty much like an RSS feed. I don't
>> know how those are generated, but whatever requests them knows what to do
>> with them. What I return should also be recognizable as an XML document.
>> What is the best way to do this?
>>
>> Thanks!
>> Tony

>


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      07-27-2008
re:
!> I am not sure which SQL books online you mean.
!> Could you post a URL or two?

SQL Server Books Online...

General info :
http://msdn.microsoft.com/en-us/library/ms166018.aspx

Download :
http://www.microsoft.com/downloads/d...displaylang=en





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
======================================
"Anthony Bollinger" <> wrote in message news:uN9CVi$...
> Thank you for your answer. I am not sure which SQL books online you mean. Could you post a URL or two?
>
> I do not think the issue I am having is proper XML, since I have that, but rather it is not identified on the
> receiving end as XML, even though the returned file is properly formatted. In fact, my first line is:
>
> <?xml version="1.0" encoding="utf-8" ?>
>
> And the remainder is a full XML document.
>
> Unfortunately, I must need to set something additional in the web service response, because consumers are not
> recognizing this as an XML file. Is there a way to set the type of the response? I think I have seen this.
>
> Many thanks! --Tony
>
> "Cowboy (Gregory A. Beamer)" <> wrote in message
> news:%...
>>I do not have an answer right this second, as it has been awhile, but the answer is located in books online.
>>
>> By default, you get an XML snippet from the FOR XML features in SQL Server. There is either a flag that returns a
>> proper root or an easy way to get it to return. Then you will have valid XML.
>>
>> If I get the chance, I will post, but take a look at the SQL books online FOR XML documentation and you should find
>> the answer.
>>
>> --
>> Gregory A. Beamer
>> MVP, MCP: +I, SE, SD, DBA
>>
>> Subscribe to my blog
>> http://gregorybeamer.spaces.live.com/lists/feed.rss
>>
>> or just read it:
>> http://gregorybeamer.spaces.live.com/
>>
>> ********************************************
>> | Think outside the box! |
>> ********************************************
>> "Anthony Bollinger" <> wrote in message news:%239C2%23$...
>>> This is my first attempt at writing an XML web service.
>>>
>>> I have a query successfully written for SQL Server that returns XML data using FOR XML AUTO. It seems rather than
>>> processing the XML and building a text string in XML format to return, there should be some way to directly return
>>> the XML I get from SQL Server. What I seem to be getting is a properly formatted XML string that is not identified
>>> as XML (not sure why), but I want this to work pretty much like an RSS feed. I don't know how those are generated,
>>> but whatever requests them knows what to do with them. What I return should also be recognizable as an XML document.
>>> What is the best way to do this?
>>>
>>> Thanks!
>>> Tony

>>

>



 
Reply With Quote
 
Anthony Bollinger
Guest
Posts: n/a
 
      07-27-2008
Thanks for that. Also, I think you are referring to the ROOT
keyword/function which will generate a root node around your XML elements in
query results returned from SQL 2005. --Joe

 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      07-29-2008
Yes, that is it. I assume you found the SQL books online file?

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
"Anthony Bollinger" <> wrote in message
news:...
> Thanks for that. Also, I think you are referring to the ROOT
> keyword/function which will generate a root node around your XML elements
> in query results returned from SQL 2005. --Joe


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using document.load() to get html NOT xml document icogs Javascript 0 01-31-2008 04:02 AM
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
Refer to an XML document from within an XML document Manish Hatwalne XML 1 07-13-2004 10:24 AM
Help on including one XML document within another XML document using XML Schemas Tony Prichard XML 0 12-12-2003 03:18 PM



Advertisments