Solved

create webservice

Posted on 2008-10-01
9
163 Views
Last Modified: 2013-11-07
i need to create a simple webservice that will pick up 2 columns from my sql server db and create an xml file.  
my query is "select lat,lng,info from table"
my xml file needs to look like sample below.

please any ideas?

<markers>
     <marker lat="43.65654" lng="-79.90138" label="Marker One">
      <infowindow><![CDATA[
        Some stuff to display in the<br>First Info Window
      ]]></infowindow>
     </marker>
   </markers>
0
Comment
Question by:gianitoo
  • 5
  • 4
9 Comments
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 22618744
Why cant you just have a Function in your WebService & then Create a String within your function which will build the XML output, and then have your Function return that String.
0
 
LVL 1

Author Comment

by:gianitoo
ID: 22618768
ok, do you have a sample code.  i am new with webservices
0
 
LVL 23

Accepted Solution

by:
Saqib Khan earned 500 total points
ID: 22618843
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 1

Author Comment

by:gianitoo
ID: 22618889
Ok I did, it does not tell me how to conect to my db and consume an xml file though.  
do you know how to accomplish this?
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 22618941
so that means, you never worked on a ASP.net Application that connects with the Database? if not then you gonna have to do alot of reading.

You need to start with how to Read data using Asp.net (Depending upon what data source you are using). once you know how to read data then you can use that technique within your WebService to return the XML string within Your Function.
0
 
LVL 1

Author Comment

by:gianitoo
ID: 22618976
I do know how to connect.  i will add my connection tomorrow and return the data that i need.  
perhaps you can guide me a little.  
I am about to head home.  
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 22619064
sure.

Import your data provider Namespace.
Connect to your DB
Write a Function to retuen results
Then have that Function String the Xml String.

any help let me know.
0
 
LVL 1

Author Comment

by:gianitoo
ID: 22626714
      ok this connection below returns my data.  how can i shoot the xml file fom this data?

Dim conn As New Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("connectionUSSL"))
                   
        conn.Open()
        Dim cmd As New Data.SqlClient.SqlCommand("salesquoteschecker", conn)
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.Add("@ID", SqlDbType.Int).Value = Request.QueryString("id").ToString()
        Dim dr As Data.SqlClient.SqlDataReader = Nothing
 
        dr = cmd.ExecuteReader()
 
        While dr.Read()
 
            Session("longitude") = dr("longitude").ToString()
            Session("latitude") = dr("latitude").ToString()
Session("info") = dr("info").ToString()

       
           
        End While
 
        conn.Close()
        conn.Dispose()
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 22627022
Below needs to be in a WebService Function.

Dim conn As New Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("connectionUSSL"))
                   
        conn.Open()
        Dim cmd As New Data.SqlClient.SqlCommand("salesquoteschecker", conn)
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.Add("@ID", SqlDbType.Int).Value = Request.QueryString("id").ToString()
        Dim dr As Data.SqlClient.SqlDataReader = Nothing
 
        dr = cmd.ExecuteReader()
  Dim longitude as double
  Dim latitude as double
  Dim info as string
  Dim xmlString as string = ""

        While dr.Read()
 
            longitude  = dr("longitude").ToString()
            latitude  = dr("latitude").ToString()
           info  = dr("info").ToString()

           xmlString = xmlString & "<xml><mytag value='"& longitude &"'></xml>"
           
        End While
 
        conn.Close()
        conn.Dispose()

    Return xmlString


so read the above article on how to create a method, then modify the xmlString  variable to create your string and then return it using that method.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question