3 calling web services methods, Calling web services methods -14, Calling web services methods – Echelon i.LON SmartServer 2.0 User Manual
Page 336

i.LON SmartServer 2.0 Programmer’s Reference
20-14
20.2.3
Instantiating the Web Service Client in Visual Basic .NET 3.5
The following example shows how to instantiate the Web service in Visual Basic. NET:
Imports
System
Imports
System.Collections.Generic
Imports
System.Linq
Imports
System.Text
Imports
System.ServiceModel
'make sure you add this statement to iLON_SoapCalls class
Public
Class
iLON_SoapCalls
'your SmartServer’s IpAddress
Public
_iLonEndpointIpAddress
As
String
=
"<SmartServer IP address>"
'your SmartServer’s Web service reference
Public
_iLON
As
iLON_SmartServer.iLON100portTypeClient =
Nothing
'''
''' Instantiate the SmartServer Web service for .NET 3.0 and 3.5 (NOT 2.0)
'''
Public
Sub
BindClientToSmartServer()
' Specify the binding to be used for the client.
Dim
binding
As
BasicHttpBinding =
New
BasicHttpBinding()
' Initialize the namespace
binding.Namespace =
"http:'wsdl.echelon.com/web_services_ns/ilon100/v4.0/message/"
' Obtain the URL of the Web service on the i.LON SmartServer.
Dim
endpointAddress
As
System.ServiceModel.EndpointAddress =
New
System.ServiceModel.EndpointAddress(
"http://"
+ _iLonEndpointIpAddress +
"/WSDL/iLON100.wsdl"
)
' Instantiate the SmartServer Web service object with this address and binding.
_iLON =
New
iLON_SmartServer.iLON100portTypeClient(binding, endpointAddress)
' uncomment the lines below to enable authentication
' binding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly
' binding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Basic
' _iLON.ChannelFactory.Credentials.UserName.UserName = "ilon"
' _iLON.ChannelFactory.Credentials.UserName.Password = "ilon"
End
Sub
'''
''' Close the SmartServer Web service
'''
Public
Sub
CloseBindingToSmartServer()
' Closing the client gracefully
' closes the connection and cleans up resources
Try
_iLON.Close()
Finally
_iLON =
Nothing
End
Try
End
Sub
End
Class
20.3
Calling Web Services Methods
The following examples demonstrate how to read and write values to a data point in Visual C# .NET
3.5, Visual C#.NET 2.0, and Visual Basic .NET 3.5, and how to setup a Web connection between a
SmartServer and a WebBinder Target Server.