Solved

create webservice

Posted on 2008-10-01
9
160 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:adilkhan
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:
adilkhan earned 500 total points
ID: 22618843
0
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 23

Expert Comment

by:adilkhan
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:adilkhan
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:adilkhan
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now