Into this example we will call a program by using the following method :
EacXML.XMLExecRequest,available into the namespace Easycom.
We call the Open List of Authorized Users (QGYOLAUS) IBM API. It provides information about the authorized users of the system.
Assuming we have this XML file(Easycom_Xml_Define_In.xml):
<?xml version="1.0" encoding="utf-8" standalone="yes"?><Easycom LogFile="/tmp/xml_demo_cedrick.log" DebugLog="259">
<define>
<file type="file" stmf="stmf" />
</define>
</Easycom>
And assuming we have this other XML file (Easycom_Xml_Program_In.xml):
<?xml version="1.0" encoding="utf-8" standalone="yes"?><Easycom LogFile="/tmp/xml_demo_cedrick.log" DebugLog="259">
<Program Name="name">
<parameterList></parameterList>
</Program>
</Easycom>
These files are present into the following directory:
AppliDemoXml\NewAppliDemoXml\bin\Release
By using the System.Xml.Linq classes, it is pretty easy to modify XML files and call program:
///////////////////////////////////////////////// 1) Load program prototypes
String Type = "PCML";
String stmf1 = "/usr/local/easycom/PCML/QGYOLAUS.pcml";
doc = XDocument.Load("Easycom_Xml_Define_In.xml");
Elmt = doc.Root.Element("define").Element("file");
Elmt.Attribute("type").Value = Type;
Elmt.Attribute("stmf").Value = stmf1;
stringXMLOut = myEacXML.XmlExecRequest(XMLToString(doc));
///////////////////////////////////////////////// 2) Call QGYOLAUS system API
doc = XDocument.Load("Easycom_Xml_Program_In.xml");
Elmt = doc.Root.Element("Program");
Elmt.Attribute("Name").Value = "QGYOLAUS";
stringXMLOut = myEacXML.XmlExecRequest(XMLToString(doc));
This is the first request sent to the EASYCOM server to load prototype of QGYOLAUS and the EASYCOM server response:
REQUEST:
<?xml version="1.0" encoding="utf-8" standalone="yes"?><Easycom LogFile="/tmp/xml_demo_cedrick.log" DebugLog="259">
<define>
<file type="PCML" stmf="/usr/local/easycom/PCML/QGYOLAUS.pcml" />
</define>
</Easycom>
-----------------------------
RESPONSE:
<?xml version="1.0" encoding="UTF-8" ?>
<Easycom Version="2.01"/>
This is the second request sent to the EASYCOM server to call QGYOLAUS and the EASYCOM server response :
=============================================================
REQUEST:
<?xml version="1.0" encoding="utf-8" standalone="yes"?><Easycom LogFile="/tmp/xml_demo_cedrick.log" DebugLog="259">
<Program Name="QGYOLAUS">
<parameterList></parameterList>
</Program>
</Easycom>
-----------------------------
RESPONSE:
<?xml version="1.0" encoding="UTF-8" ?>
<Easycom Version="2.01">
<Program Name="qgyolaus">
<ParameterList>
<receiver Type="Array" count="0"/>
<listInfo Type="Struct" Struct="listInfo">
<totalRcds Type="Int">106</totalRcds>
<rcdsReturned Type="Int">0</rcdsReturned>
<rqsHandle Type="Byte" Encoding="BASE64">AAAAAQ==</rqsHandle>
<rcdLength Type="Int">62</rcdLength>
<infoComplete Type="Char">C</infoComplete>
<dateCreated Type="Char">1160707</dateCreated>
<timeCreated Type="Char">110642</timeCreated>
<listStatus Type="Char">2</listStatus>
<lengthOfInfo Type="Int">0</lengthOfInfo>
<firstRecord Type="Int">0</firstRecord>
</listInfo>
</ParameterList>
</Program>
</Easycom>
=============================================================
If after we use the Get List Entries (QGYGTLE) IBM API, we will be able to get entries from previously opened Authorized Users list.
REQUEST:
<?xml version="1.0" encoding="utf-8" standalone="yes"?><Easycom LogFile="/tmp/xml_demo_cedrick.log" DebugLog="259">
<Program Name="qgygtle">
<parameterList>
<receiverLength>6572</receiverLength>
<requestHandle>AAAAAQ==</requestHandle>
<rcdsToReturn>106</rcdsToReturn>
<STARTINGRCD>1</STARTINGRCD>
</parameterList>
</Program>
</Easycom>
-----------------------------
RESPONSE:
<?xml version="1.0" encoding="UTF-8" ?>
<Easycom Version="2.01">
<Program Name="qgygtle">
<ParameterList>
<receiver Type="Array" count="106">
<item Type="Struct" Struct="autu0150">
<NAME Type="Char">AAABBBCCCD</NAME>
<userOrGroup Type="Char">0</userOrGroup>
<groupMembers Type="Char">0</groupMembers>
<description Type="Char"/>
</item>
<item Type="Struct" Struct="autu0150">
<NAME Type="Char">ADMIN</NAME>
<userOrGroup Type="Char">0</userOrGroup>
<groupMembers Type="Char">0</groupMembers>
<description Type="Char">Responsable de la sécurité</description>
</item>
<item Type="Struct" Struct="autu0150">
<NAME Type="Char">ZS5250DEMO</NAME>
<userOrGroup Type="Char">0</userOrGroup>
<groupMembers Type="Char">0</groupMembers>
<description Type="Char">Zend 5250 demo user</description>
</item>
</receiver>
<listInfo Type="Struct" Struct="listInfo">
<totalRcds Type="Int">106</totalRcds>
<rcdsReturned Type="Int">106</rcdsReturned>
<rqsHandle Type="Byte" Encoding="BASE64">AAAAAQ==</rqsHandle>
<rcdLength Type="Int">62</rcdLength>
<infoComplete Type="Char">C</infoComplete>
<dateCreated Type="Char">1160707</dateCreated>
<timeCreated Type="Char">110642</timeCreated>
<listStatus Type="Char">2</listStatus>
<lengthOfInfo Type="Int">6572</lengthOfInfo>
<firstRecord Type="Int">1</firstRecord>
</listInfo>
</ParameterList>
</Program>
</Easycom>
=============================================================
By using the System.Xml.Linq classes, it is also pretty easy to parse XML out and retrieve users names (Program.ParameterList.receiver.item.NAME elements in red above):
XElement root2 = XElement.Parse(stringXMLOut);
List<string> userList = new List<string>();
IEnumerable<XElement> item2 =
from el in root2.Element("Program").Element("ParameterList").Element("receiver").Elements("item")
select el.Element("NAME");
foreach (XElement el in item2)
{
userList.Add(el.Value);
}
BindingSource bs = new BindingSource();
bs.DataSource = userList;
checkedListBoxUsers.DataSource = bs;