4 Loop Web Development
  • Services
  • Information
  • Contact
  • Services
  • Information
  • Contact

eTapestry ASP.NET Example

Recently I had to work with a site called eTapestry which is a good program but their API help isn't the best for the .net world.   So I got an example working and decided to post what I have so maybe you can get started must faster then I did.

 

Step 1: Create a temp database so you can figure out how their system works.

 

Step 2: In Visual Studio add the web reference.  Find the latest WSDL location at the eTapestry API Documentation page.  NOTE: I couldn't get a Service Reference to work so I had to use the advanced button and add the old Web Reference way.

 

Step 3: Create new page.  I called it etapestry.aspx.   Add a button called 'btnRun' and a label called ltlOutput.

 

Here is my codebehind for etapestry.aspx.vb

Imports etapestry

Partial Class etapestry
    Inherits System.Web.UI.Page

    Dim sUser As String = "yourusername" 'MUST BE CHANGED
    Dim sPwd As String = "yourpassword" 'MUST BE CHANGED
    Dim sCategoryName As String = "LYBUNT & SYBUNT" 'CHANGE TO TESTING CATEGORY
    Dim sQueryName As String = "Gave Last Year" 'CHANGE TO TESTING QUERY
    Dim _etService As com.etapestry.sna.Service = New com.etapestry.sna.Service
    Dim _etQueryRequest As com.etapestry.sna.PagedExistingQueryResultsRequest = New com.etapestry.sna.PagedExistingQueryResultsRequest
    Dim _etQueryResponse As com.etapestry.sna.PagedQueryResultsResponse = New com.etapestry.sna.PagedQueryResultsResponse
    Dim _etAccount As com.etapestry.sna.Account = New com.etapestry.sna.Account

    Protected Sub btnRun_Click(sender As Object, e As System.EventArgs) Handles btnRun.Click
        Dim sEndPoint As String = ""

        _etService.CookieContainer = New System.Net.CookieContainer()
        sEndPoint = _etService.login(sUser, sPwd)
        Dim sOutput As String = ""
        _etService.Url = sEndPoint
        If _etService.login(sUser, sPwd) = "" Then
            _etQueryRequest.start = 0
            _etQueryRequest.count = 100
            _etQueryRequest.query = String.Format("{0}::{1}", sCategoryName, sQueryName)
            _etQueryResponse = _etService.getExistingQueryResults(_etQueryRequest)
            Dim iMax As Integer = _etQueryResponse.total
            For iLoop As Integer = 0 To iMax - 1
                _etAccount = _etQueryResponse.data(iLoop)

                lblOutput.Text &= "Name: " & _etAccount.name & "
Address: " & _etAccount.address & "
City: " & _etAccount.city & "
State: " & _etAccount.state & "
Postal Code: " & _etAccount.postalCode & "
ID: " & _etAccount.id & "
" Next End If End Sub End Class

Save and test it out.