VB 6.0 - How to call a method in webservice in visual basic

Asked By balaji mogadali on 19-Oct-11 07:12 AM
hi frds
how to call a method in webservice in visual basic

pls help 
TSN ... replied to balaji mogadali on 19-Oct-11 07:15 AM
hi..


use this function to get data from a web service.

Private Function HttpGetRequest(url As String) As DOMDocument
  Dim req As XMLHTTP60
  Set req = New XMLHTTP60
  req.Open "GET", url, False
  req.send ""
 
  Dim resp As DOMDocument
  If req.responseText <> vbNullString Then
    Set resp = New DOMDocument60
    resp.loadXML req.responseText
  Else
    Set resp = req.responseXML
  End If
  Set HttpGetRequest = resp
End Function


refer...

http://msdn.microsoft.com/en-us/library/aa730836%28v=vs.80%29.aspx
Chintan Vaghela replied to balaji mogadali on 19-Oct-11 09:23 AM

Hello,

 

Try following approach,

 

Create WS

 

<WebMethod()> Public Function Add(a As Integer, b As Integer) As Integer
   Return(a + b)
End Function
 
<WebMethod()> Public Function Subtract(A As System.Single, B As System.Single) As System.Single
     Return A - B
End Function
 
<WebMethod()> Public Function Multiply(A As System.Single, B As System.Single) As System.Single
     Return A * B
End Function
 
<WebMethod()> Public Function Divide(A As System.Single, B As System.Single) As System.Single
If B = 0
Return -1
End If
Return Convert.ToSingle(A / B)
End Function
       

Call WS

 
  • Create an instance of the proxy object that was created. Place this code in the Main procedure of the Module1 module:

 

Dim myMathService As localhost.MathService = New localhost.MathService()

                   

  • Invoke a method on the proxy object created in the previous step:

 

Console.Write("2 + 4 = {0}", myMathService.Add(2,4))

                   

      

 

 

Hope this is helpful !

 

Thanks