In order to send SOAP messages, we will need a helper class that will initialize type binding. In particular, this class will provide methods allowing to set up an Agent message header containing the URL, the session ID, and the target operator name.
public class Binder
{
// Method to bind types.
// Parameters
// bindingType: Object name.
// target: If set to true, will add the "target"
// argument to the message header.
// If set to false, will omit the "target"
// argument.
// "Target" is the name of the Agent
// operator that processes a particular
// request type on the server side.
// For some requests, this argument
// must be omitted.
//
public System.Object InitBinding(System.Type bindingType, bool target)
{
string typeName = bindingType.Name;
System.Object Binding =
bindingType.GetConstructor(System.Type.EmptyTypes).Invoke(null);
bindingType.GetProperty("Url").SetValue(Binding, URL, null);
packet_headerType header = new packet_headerType();
header.session = session;
if (target)
{
header.target = new string[1];
header.target[0] = typeName.Replace("Binding", "");
}
bindingType.GetField("packet_header").SetValue(Binding, header);
return Binding;
}
// Same as above, but will add the "target" argument to the
// message header by default.
public System.Object InitBinding(System.Type bindingType)
{
string typeName = bindingType.Name;
System.Object Binding =
bindingType.GetConstructor(System.Type.EmptyTypes).Invoke(null);
bindingType.GetProperty("Url").SetValue(Binding, URL, null);
packet_headerType header = new packet_headerType();
header.session = session;
header.target = new string[1];
header.target[0] = typeName.Replace("Binding", "");
bindingType.GetField("packet_header").SetValue(Binding, header);
return Binding;
}
public Binder(string url,string sess)
{
URL = url;
session = sess;
}
string URL;
string session;
}