StrataFrame Forum

Webservices

http://forum.strataframe.net/Topic859.aspx

By Kevin Lingofelter - 4/20/2006

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!

By Trent L. Taylor - 4/20/2006

Kevin,

StrataFrame can definitly be used within web services and has functionality to serialize and de-serialize business objects.  We have several users that have create webservices projects with StrataFrame. As for whether it is a good fit for your project, I don't know.  It depends on what you are trying to accomplish.  If you want your WinForms and WebForms application to be a central point of communication, then this might be a way to go.  The only time you really need to do this (for WinForms) is when you are going to have a connection at a remote location and will not have a VPN between to two locations.  Otherwise, it is usually better to just point the WinForms application to the remote location with your connection string.

BTW, I haven't forgotten about you and your Access View issue.  We are working on getting out the 1.4 build, so I appologize for any delays.

By Kevin Lingofelter - 4/20/2006

Sounds good. Can you give me a pointer or two on wiring webservices to the BO? How does the connection string management work? Sorry, I know these are pretty elementry questions.

Kevin

By Trent L. Taylor - 4/20/2006

There is no such thing as an "elementary" question Wink.  In the case of a WebService, there is really no need to use the StrataFrame Connection Manager and wizard.  Since this will reside in a static location, it will behave more like a website than a windows application.

You can define your connection strings manually by adding the following code:

'------------------------------------
' Setting the data sources manually
'------------------------------------

'-- SQL Server
DataLayer.DataSources.Add(New SqlDataSourceItem("", "myconnectionstring"))

'-- Oracle
DataLayer.DataSources.Add(New OracleDataSourceItem("", "myconnectionstring"))

'-- Microsoft Access
DataLayer.DataSources.Add(New AccessDataSourceItem("", "myconnectionstring"))

'-- Visual Fox Pro
DataLayer.DataSources.Add(New VfpDataSourceItem("", "myconnectionstring"))

Let me know if this answers your question.

By Kevin Lingofelter - 4/20/2006

Ah...so does this code go into each web method? AFAIK, there's no startup code for webservices. Is that correct?
By Trent L. Taylor - 4/21/2006

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

By Kevin Lingofelter - 4/21/2006

Perfect! Thanks a million!

Kevin

By Trent L. Taylor - 4/21/2006

Glad to help!