As the current MS C#/VB
Express Edition 2008 works defautly with .NET 3.0 or
3.5 I strictly recommend to use it instead of 2.0.
Probably you tried to
initiate the WebService using the .NET 2.0 mechanism. This is the way it works with .NET 3.x:
1. Create new project (e.g.
a console application) and be aware to choose the .NET 3.0 or 3.5 (not .NET
2.0) in the Dialog.
2. Input a name in the Name
field (I used "ForumTest").
3. Right click on the
Project in the Visual Studio SolutionExplorer and
choose "Add Service Reference.."
4. Input you WSDL sink like
("zzz.zzz.zzz.zzz" is your iLON's ip address)
"http://zzz.zzz.zzz.zzz/WSDL/v4.0/iLON100.wsdl"
5. Click the Go button, and
then enter a name for the Web Service Reference in the Namespace field (e.g.
"iLON_WS")
6. Input this code in your
"Program.cs" or "Program.vb"
(I used C#):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ForumTest2
{
class iLON_SoapCalls
{
// CHANGE IT
HERE: your i.LON's IpAddress, e.g. "172.25.137.101"
public const string
_iLonEndpointIpAddress = "zzz.zzz.zzz.zzz";
static private iLON_WS.iLON100portTypeClient _iLON = null;
/// <summary>
/// ATTENTION:
Instantiates the i.LON web service for .NET 3.0 and 3.5 (NOT 2.0)
/// </summary>
static void Main(string[ args) {
if(_iLonEndpointIpAddress.Contains("z"))
{
System.Diagnostics.Debug.Write("\nFAULT:
please set the correct i.LON SmartServer ip-address !!!\n\n");
return;
}
//
Specify the binding to be used for the client.
System.ServiceModel.Channels.Binding binding
=
new System.ServiceModel.BasicHttpBinding();
//
Initialize the namespace
binding.Namespace
= "http://wsdl.echelon.com/web_services_ns/ilon100/v4.0/message/";
// The
size of the messages that can be received on the wire by services using the
BasicHttpBinding
// is
bounded by the amount of memory allocated for each message.
// This
bound on message size is intended to limit exposure to DoS-style attacks.
// We
have to increase it for the i.LON to be able to receive all messages
((System.ServiceModel.BasicHttpBinding)binding).MaxReceivedMessageSize =
1000*1000;
// Obtain
the URL of the Web service on the i.LON SmartServerver.
System.ServiceModel.EndpointAddress
endpointAddress
=
new System.ServiceModel.EndpointAddress("http://"
+
_iLonEndpointIpAddress + "/WSDL/iLON100.wsdl");
//
Instantiate the i.LON web service object with this address and binding.
_iLON =
new iLON_WS.iLON100portTypeClient(binding,
endpointAddress);
// Do
some stuff on the iLON
try
{
DoSomething();
}
catch
(Exception ex) {
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
// close
the i.LON web service gracefully
// closes
the connection and cleans up resources
try
{
_iLON.Close();
}
finally
{
_iLON =
null;
}
}
static private void DoSomething() {
iLON_WS.E_xSelect xSel =
new iLON_WS.E_xSelect();
xSel.xSelect
= "//Item[@xsi:type=\"Fb_Cfg\"]";
iLON_WS.Item_Coll items = _iLON.List(xSel);
System.Diagnostics.Debug.WriteLine(items.Item.GetLength(0).ToString() + " Items responded." );
}
}
}
7. That's all