Solved

create webservice

Posted on 2008-10-01
9
161 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
3 Use Cases for Connected Systems

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

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

18 Experts available now in Live!

Get 1:1 Help Now