XML Feed

S

Steve Peterson

Hello

I need to provide a live XML feed from my web application to a 3rd party.
The 3rd party needs data from our database in XML format which will be
fromatted & presented on a web page sort of an RSS scenario. The problem is
I'm not sure how to to provide a dynamic XML file, or rather the latest data
will be returned as XML to the 3rd party.

I'm assuming this is a good scenario for a web service, but have no clue
where to begin. If anyone has faced this before & could point me in the
right direction to read up on this, I would appreciate it.

TIA
Steve
 
K

Ken Cox [Microsoft MVP]

Hi Steve,

Yes, a Web service would be a good way to go to provide XML. Here's a quick
example of how you can return a dataset that is very usable XML by anyone
who knows that they are doing:

' filename: wsdata.asmx

<%@ WebService Language="vb" Codebehind="wsdata.asmx.vb"
Class="p4320work.wsdata" %>


'filename: wsdata.asmx.vb
Imports System.Web.Services

<System.Web.Services.WebService(Namespace :=
"http://tempuri.org/p4320work/wsdata")> _
Public Class wsdata
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function SendData() As DataSet
Return CreateDataSource()
End Function
Function CreateDataSource() As DataSet
Dim dt As New DataTable
Dim dr As DataRow
Dim ds As New DataSet
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
ds.Tables.Add(dt)
Return ds
End Function 'CreateDataSource
End Class

Ken
Microsoft MVP [ASP.NET]
Toronto
 
S

Steve Peterson

Thanks Ken

I appreciate you taking the time to reply on Christmas!

Steve


Ken Cox said:
Hi Steve,

Yes, a Web service would be a good way to go to provide XML. Here's a
quick example of how you can return a dataset that is very usable XML by
anyone who knows that they are doing:

' filename: wsdata.asmx

<%@ WebService Language="vb" Codebehind="wsdata.asmx.vb"
Class="p4320work.wsdata" %>


'filename: wsdata.asmx.vb
Imports System.Web.Services

<System.Web.Services.WebService(Namespace :=
"http://tempuri.org/p4320work/wsdata")> _
Public Class wsdata
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function SendData() As DataSet
Return CreateDataSource()
End Function
Function CreateDataSource() As DataSet
Dim dt As New DataTable
Dim dr As DataRow
Dim ds As New DataSet
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
ds.Tables.Add(dt)
Return ds
End Function 'CreateDataSource
End Class

Ken
Microsoft MVP [ASP.NET]
Toronto


Steve Peterson said:
Hello

I need to provide a live XML feed from my web application to a 3rd party.
The 3rd party needs data from our database in XML format which will be
fromatted & presented on a web page sort of an RSS scenario. The problem
is I'm not sure how to to provide a dynamic XML file, or rather the
latest data will be returned as XML to the 3rd party.

I'm assuming this is a good scenario for a web service, but have no clue
where to begin. If anyone has faced this before & could point me in the
right direction to read up on this, I would appreciate it.

TIA
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top