Looking at Web Services with Visual Studio 2005

Sign in to queue

The Discussion

  • User profile image
    Khamul
    One question: localhost.com? What the?
  • User profile image
    guercheLE

    Dear Thom,

    I created a sample quite similar to yours, but using Microsoft Visual Web Developer 2005 Express Edition and Microsoft Visual Basic 2005 Express Edition. Moreover, I tried to implement a way to client(s) send changes back to server, through EmployeesUpdate method, but it is not working. Would you mind looking at code below and pinpointing what I have done wrong?

    Regards,

    Luciano Evaristo Guerche
    Taboão da Serra, SP, Brazil

    'Service.vb
    '-------------------------------------------------------------------------------
    Imports System.Web
    Imports System.Web.Services
    Imports System.Web.Services.Protocols

    <System.Web.Services.WebService(Namespace:="http://www.rabobank.com/dataaccess/adventureworks", Description:="Provides data access to Adventureworks database")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Public Class Service
        Inherits System.Web.Services.WebService

        <WebMethod()> _
        Public Function EmployeesGetData() As AdventureWorks.EmployeesDataTable
            Return CType(New AdventureWorksTableAdapters.EmployeesTableAdapter, AdventureWorksTableAdapters.EmployeesTableAdapter).GetData()
        End Function

        <WebMethod()> _
        Public Function EmployeesUpdate(ByVal employeeDataTable As AdventureWorks.EmployeesDataTable) As Integer
            Return CType(New AdventureWorksTableAdapters.EmployeesTableAdapter, AdventureWorksTableAdapters.EmployeesTableAdapter).Update(employeeDataTable)
        End Function
    End Class


    'EmployeesForm.vb
    '-------------------------------------------------------------------------------
    Public Class EmployeesForm
        Private Sub EmployeesForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Me.AdventureWorks.Merge(CType(New Global.WindowsApplication1.localhost.Service, Global.WindowsApplication1.localhost.Service).EmployeesGetData())
        End Sub

        Private Sub EmployeesBindingNavigatorRefreshItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Me.AdventureWorks.Merge(CType(New Global.WindowsApplication1.localhost.Service, Global.WindowsApplication1.localhost.Service).EmployeesGetData())
        End Sub

        Private Sub EmployeesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            CType(New Global.WindowsApplication1.localhost.Service, Global.WindowsApplication1.localhost.Service).EmployeesUpdate(Me.AdventureWorks.Employees)
        End Sub
    End Class

    'Reference.vb
    '-------------------------------------------------------------------------------
    Option Strict Off
    Option Explicit On

    Imports System
    Imports System.ComponentModel
    Imports System.Diagnostics
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.Xml.Serialization

    '
    'This source code was auto-generated by Microsoft.VSDesigner, Version 2.0.50727.42.
    '
    Namespace localhost
        '''<remarks/>
        <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42"),  _
         System.Diagnostics.DebuggerStepThroughAttribute(),  _
         System.ComponentModel.DesignerCategoryAttribute("code"),  _
         System.Web.Services.WebServiceBindingAttribute(Name:="ServiceSoap", [Namespace]:="http://www.rabobank.com/dataaccess/adventureworks")>  _
        Partial Public Class Service
            Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

            'abridged for brevity's sake...

            '''<remarks/>
            <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.rabobank.com/dataaccess/adventureworks/EmployeesUpdate", RequestNamespace:="http://www.rabobank.com/dataaccess/adventureworks", ResponseNamespace:="http://www.rabobank.com/dataaccess/adventureworks", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>  _
            Public Function EmployeesUpdate(ByVal employeeDataTable As AdventureWorks.EmployeesDataTable) As Integer
                Dim results() As Object = Me.Invoke("EmployeesUpdate", New Object() {employeeDataTable})
                Return CType(results(0),Integer)
            End Function
        End Class
    End Namespace

Add Your 2 Cents