Webservices


Author
Message
Kevin Lingofelter
Kevin Lingofelter
StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)
Group: Forum Members
Posts: 77, Visits: 804
Hello,

I have a BO project to ecapsulate all the data access.

I'd like to now create a webservice project to utilize the BOs I created (which will be consumed by both web and win forms).

Would webservices be a good fit here? I haven't played with webservices much, so I am beginning my google quest, but wanted to see if anyone here has implemented this and would be willing to share their ideas.

Thanks!

Replies
Kevin Lingofelter
Kevin Lingofelter
StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)
Group: Forum Members
Posts: 77, Visits: 804
Ah...so does this code go into each web method? AFAIK, there's no startup code for webservices. Is that correct?
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
You can do this, but you do not need to add the connection everytime.  The DataSources are a shared and a webserive runs in an application pool like a website.  So you do not need to add teh data connection each time.  One thing you can do if you are going to use a WebMethod is to just check on the count of the DataSources collection.  If it is 0, then add the connection.  Otherwise, leave it alone because it has already been setup.

<WebMethod()> _
    Public Function SampleMethod() As String
        '-- Determine if the connection has been established
        If MicroFour.StrataFrame.Data.DataBasics.DataSources.Count = 0 Then
            DataBasics.DataSources.Add(New SqlDataSourceItem("", "MyConnectionSTring"))
        End If

        Return "Whatever"
    End Function

- or - Tongue

Much Better Solution
You can add a global.asax to your webservice project and add the code once in the Application_Startup method and never worry about it...

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
     DataBasics.DataSources.Add(New SqlDataSourceItem("", "MyConnectionSTring"))
End Sub

Kevin Lingofelter
Kevin Lingofelter
StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)
Group: Forum Members
Posts: 77, Visits: 804
Perfect! Thanks a million!

Kevin

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Glad to help!
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Kevin Lingofelter - 20 Years Ago
Trent L. Taylor - 20 Years Ago
Kevin Lingofelter - 20 Years Ago
Trent L. Taylor - 20 Years Ago
Kevin Lingofelter - 20 Years Ago
                         You can do this, but you do not need to add the connection everytime....
Trent L. Taylor - 20 Years Ago
                             Perfect! Thanks a million! Kevin
Kevin Lingofelter - 20 Years Ago
                                 Glad to help!
Trent L. Taylor - 20 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search