Echelon i.LON SmartServer 2.0 User Manual
Page 333

i.LON SmartServer 2.0 Programmer’s Reference
20-11
class iLON_WebService : iLON_SmartServer.iLON100
// iLON_SmartServer refers to the name of the Web reference created in step 4
{
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest res = (HttpWebRequest)base.GetWebRequest(uri);
res.KeepAlive = false;
return res;
}
}
6. You should now use the iLON_WebService class to instantiate the SmartServer Web
reference as described in section 20.2.2, Instantiating the Web Service Client in Visual C#
.NET 2.0.
20.2
Instantiating and Initializing the Web Service Client
Before you can use the functions of the SOAP/XML interface, you must instantiate the Web service
object that was referenced in the previous section from within your application. This section contains
programming samples written in Visual C# .NET 3.5, Visual C#.NET 2.0, and Visual Basic .NET 3.5
that demonstrate how to do so. For simplicity, the programming samples include all the code required
to instantiate the Web service within a single function. This function, for example, could be an event
handler for a button click event. You can instantiate the Web service in any routine, although you
should generally consider doing this in an initialization routine.
Once you have instantiated the Web service object, you have to set the Web service’s URL. This is
also known as the SOAP endpoint, EndPointURL, or Service endpoint, depending on which
development tool you are using. This is the destination on the SmartServer where SOAP messages
from your application will be sent.
In addition, if you have password-protected the WSDL file on the SmartServer with the i.LON Web
Server Security and Parameters utility, your application needs to specify the correct user ID and
password to successfully send SOAP messages to the SmartServer. You can perform this task after
you instantiate the Web service, as shown below. For more information on the i.LON Web Server
Security and Parameters utility, see Appendix C of the i.LON SmartServer 2.0 User’s Guide.
20.2.1
Instantiating the Web Service Client in Visual C# .NET 3.5
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.ServiceModel;
//make sure you add this statement to iLON_SoapCalls class