Solved

create webservice

Posted on 2008-10-01
9
165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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