Echelon i.LON SmartServer 2.0 User Manual
Page 380
i.LON SmartServer 2.0 Programmer’s Reference
21-28
{
// Specify the binding to be used for the client.
BasicHttpBinding
binding =
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 SmartServer.
System.ServiceModel.
EndpointAddress
endpointAddress
=
new
System.ServiceModel.
EndpointAddress
(
"http://"
+ _iLonEndpointIpAddress +
"/WSDL/iLON100_System.wsdl"
);
// Instantiate the i.LON web service object with this address and binding.
_iLON =
new
iLON_SmartServer_System.
iLON100portTypeClient
(binding, endpointAddress);
// Uncommment 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";
}
///
///
Close the i.LON web service
///
static
public
void
CloseBindingToSmartServer()
{
// Closing the client gracefully
// closes the connection and cleans up resources
try
{
_iLON.Close();
}
finally
{
_iLON =
null
;
}
}
}
}
Web Service Instantiation in iLON_SoapCalls Class for NET 2.0 Framework
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.ServiceModel;
namespace
SystemServiceExample
{
class
iLON_SoapCalls
{
// your SmartServer’s Web service reference
static
public
iLON_SmartServer_System _iLON =
null
;
///
///
Instantiates the SmartServer Web service for .NET 2.0
///
static
public
void
BindClientToSmartServer(
string
iLonEndpointIpAddress)
{
_iLON =
new
iLON_WebService
();
String
strOrigUrl = _iLON.Url;
_iLON.Url = strOrigUrl.Replace(
"localhost"
, iLonEndpointIpAddress);
_iLON.messagePropertiesValue =
new
iLON_SmartServer.
messageProperties
();
// uncomment the 2 lines below to enable authentication