Patrick Goovaerts
2005-09-19 12:44:00 UTC
I'm trying to use PCML to make program calls to our iSeries. All works fine
from within WDSCi but I cannot run my app's from Windows Commandline.
Finally I decided to start with the example in the JT400 Toolbox but even
then, it isn't working!!!
I get same 'PCML document source 'xxxx' not found exceptions, even when I
try to serialize the document from command line...
Help is veeeeeryyyyy muuuuuuch appreciated!
**********************************************************
JAVACODE:
**********************************************************
import com.ibm.as400.data.ProgramCallDocument;
import com.ibm.as400.data.PcmlException;
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400Message;
// Example program to call "Retrieve User Information" (QSYRUSRI) API
public class qsyrusri {
public qsyrusri() {
}
public static void main(String[] argv)
{
AS400 as400System; // com.ibm.as400.access.AS400
ProgramCallDocument pcml; // com.ibm.as400.data.ProgramCallDocument
boolean rc = false; // Return code from
ProgramCallDocument.callProgram()
String msgId, msgText; // Messages returned from the server
Object value; // Return value from
ProgramCallDocument.getValue()
System.setErr(System.out);
// Construct AS400 without parameters, user will be prompted
as400System = new AS400();
try
{
// Uncomment the following to get debugging information
//com.ibm.as400.data.PcmlMessageLog.setTraceEnabled(true);
System.out.println("Beginning PCML Example..");
System.out.println(" Constructing ProgramCallDocument for
QSYRUSRI API...");
// Construct ProgramCallDocument
// First parameter is system to connect to
// Second parameter is pcml resource name. In this example,
// serialized PCML file "qsyrusri.pcml.ser" or
// PCML source file "qsyrusri.pcml" must be found in the
classpath.
pcml = new ProgramCallDocument(as400System, "qsyrusri");
// Set input parameters. Several parameters have default values
// specified in the PCML source. Do not need to set them using
Java code.
System.out.println(" Setting input parameters...");
pcml.setValue("qsyrusri.receiverLength",
new
Integer((pcml.getOutputsize("qsyrusri.receiver"))));
// Request to call the API
// User will be prompted to sign on to the system
System.out.println(" Calling QSYRUSRI API requesting
information for the sign-on user.");
rc = pcml.callProgram("qsyrusri");
// If return code is false, we received messages from the server
if(rc == false)
{
// Retrieve list of server messages
AS400Message[] msgs = pcml.getMessageList("qsyrusri");
// Iterate through messages and write them to standard
output
for (int m = 0; m < msgs.length; m++)
{
msgId = msgs[m].getID();
msgText = msgs[m].getText();
System.out.println(" " + msgId + " - " + msgText);
}
System.out.println("** Call to QSYRUSRI failed. See messages
above **");
System.exit(0);
}
// Return code was true, call to QSYRUSRI succeeded
// Write some of the results to standard output
else
{
value = pcml.getValue("qsyrusri.receiver.bytesReturned");
System.out.println(" Bytes returned: " + value);
value = pcml.getValue("qsyrusri.receiver.bytesAvailable");
System.out.println(" Bytes available: " + value);
value = pcml.getValue("qsyrusri.receiver.userProfile");
System.out.println(" Profile name: " + value);
value =
pcml.getValue("qsyrusri.receiver.previousSignonDate");
System.out.println(" Previous signon date:" + value);
value =
pcml.getValue("qsyrusri.receiver.previousSignonTime");
System.out.println(" Previous signon time:" + value);
}
}
catch (PcmlException e)
{
System.out.println(e.getLocalizedMessage());
e.printStackTrace();
System.out.println("*** Call to QSYRUSRI failed. ***");
System.exit(0);
}
System.exit(0);
} // End main()
}
**********************************************************
PCMLDOCUMENT:
**********************************************************
<pcml version="1.0">
<!-- PCML source for calling "Retrieve user Information" (QSYRUSRI) API -->
<!-- Format USRI0150 - Other formats are available -->
<struct name="usri0100">
<data name="bytesReturned" type="int" length="4"
usage="output"/>
<data name="bytesAvailable" type="int" length="4"
usage="output"/>
<data name="userProfile" type="char" length="10"
usage="output"/>
<data name="previousSignonDate" type="char" length="7"
usage="output"/>
<data name="previousSignonTime" type="char" length="6"
usage="output"/>
<data type="byte" length="1"
usage="output"/>
<data name="badSignonAttempts" type="int" length="4"
usage="output"/>
<data name="status" type="char" length="10"
usage="output"/>
<data name="passwordChangeDate" type="byte" length="8"
usage="output"/>
<data name="noPassword" type="char" length="1"
usage="output"/>
<data type="byte" length="1"
usage="output"/>
<data name="passwordExpirationInterval" type="int" length="4"
usage="output"/>
<data name="datePasswordExpires" type="byte" length="8"
usage="output"/>
<data name="daysUntilPasswordExpires" type="int" length="4"
usage="output"/>
<data name="setPasswordToExpire" type="char" length="1"
usage="output"/>
<data name="displaySignonInfo" type="char" length="10"
usage="output"/>
</struct>
<!-- Program QSYRUSRI and its parameter list for retrieving USRI0100
format -->
<program name="qsyrusri" path="/QSYS.lib/QSYRUSRI.pgm">
<data name="receiver" type="struct" struct="usri0100"
usage="output"/>
<data name="receiverLength" type="int" length="4"
usage="input" />
<data name="format" type="char" length="8"
usage="input" init="USRI0100"/>
<data name="profileName" type="char" length="10"
usage="input" init="*CURRENT"/>
<data name="errorCode" type="int" length="4"
usage="input" init="0"/>
</program>
</pcml>
**********************************************************
ERROR WHILE RUNNING THE JAVAPGM:
**********************************************************
D:\ClipperJavaApps\resources>java qsyrusri
Beginning PCML Example..
Constructing ProgramCallDocument for QSYRUSRI API...
Exception in thread "main" java.util.MissingResourceException: PCML document
source 'qsyrusri' cannot be found.
at
com.ibm.as400.data.SystemResourceFinder.getPCMLDocument(SystemResourceFinder
.java:196)
at com.ibm.as400.data.PcmlSAXParser.<init>(PcmlSAXParser.java:98)
at
com.ibm.as400.data.ProgramCallDocument.loadSourcePcmlDocument(Program
CallDocument.java:1076)
at
com.ibm.as400.data.ProgramCallDocument.loadPcmlDocument(ProgramCallDocument.
java:979)
at
com.ibm.as400.data.ProgramCallDocument.<init>(ProgramCallDocument.java:127)
at qsyrusri.main(qsyrusri.java:38)
**********************************************************
ERROR WHILE TRYING TO SERIALIZE THE PCML-DOCUMENT:
**********************************************************
D:\ClipperJavaApps\resources>java
com.ibm.as400.data.ProgramCallDocument -serialize qsyrusri
Exception in thread "main" java.util.MissingResourceException: PCML document
source 'qsyrusri' cannot be found.
at
com.ibm.as400.data.SystemResourceFinder.getPCMLDocument(SystemResourceFinder
.java:196)
at com.ibm.as400.data.PcmlSAXParser.<init>(PcmlSAXParser.java:98)
at
com.ibm.as400.data.ProgramCallDocument.loadSourcePcmlDocument(Program
CallDocument.java:1076)
at
com.ibm.as400.data.ProgramCallDocument.main(ProgramCallDocument.java:237)
from within WDSCi but I cannot run my app's from Windows Commandline.
Finally I decided to start with the example in the JT400 Toolbox but even
then, it isn't working!!!
I get same 'PCML document source 'xxxx' not found exceptions, even when I
try to serialize the document from command line...
Help is veeeeeryyyyy muuuuuuch appreciated!
**********************************************************
JAVACODE:
**********************************************************
import com.ibm.as400.data.ProgramCallDocument;
import com.ibm.as400.data.PcmlException;
import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400Message;
// Example program to call "Retrieve User Information" (QSYRUSRI) API
public class qsyrusri {
public qsyrusri() {
}
public static void main(String[] argv)
{
AS400 as400System; // com.ibm.as400.access.AS400
ProgramCallDocument pcml; // com.ibm.as400.data.ProgramCallDocument
boolean rc = false; // Return code from
ProgramCallDocument.callProgram()
String msgId, msgText; // Messages returned from the server
Object value; // Return value from
ProgramCallDocument.getValue()
System.setErr(System.out);
// Construct AS400 without parameters, user will be prompted
as400System = new AS400();
try
{
// Uncomment the following to get debugging information
//com.ibm.as400.data.PcmlMessageLog.setTraceEnabled(true);
System.out.println("Beginning PCML Example..");
System.out.println(" Constructing ProgramCallDocument for
QSYRUSRI API...");
// Construct ProgramCallDocument
// First parameter is system to connect to
// Second parameter is pcml resource name. In this example,
// serialized PCML file "qsyrusri.pcml.ser" or
// PCML source file "qsyrusri.pcml" must be found in the
classpath.
pcml = new ProgramCallDocument(as400System, "qsyrusri");
// Set input parameters. Several parameters have default values
// specified in the PCML source. Do not need to set them using
Java code.
System.out.println(" Setting input parameters...");
pcml.setValue("qsyrusri.receiverLength",
new
Integer((pcml.getOutputsize("qsyrusri.receiver"))));
// Request to call the API
// User will be prompted to sign on to the system
System.out.println(" Calling QSYRUSRI API requesting
information for the sign-on user.");
rc = pcml.callProgram("qsyrusri");
// If return code is false, we received messages from the server
if(rc == false)
{
// Retrieve list of server messages
AS400Message[] msgs = pcml.getMessageList("qsyrusri");
// Iterate through messages and write them to standard
output
for (int m = 0; m < msgs.length; m++)
{
msgId = msgs[m].getID();
msgText = msgs[m].getText();
System.out.println(" " + msgId + " - " + msgText);
}
System.out.println("** Call to QSYRUSRI failed. See messages
above **");
System.exit(0);
}
// Return code was true, call to QSYRUSRI succeeded
// Write some of the results to standard output
else
{
value = pcml.getValue("qsyrusri.receiver.bytesReturned");
System.out.println(" Bytes returned: " + value);
value = pcml.getValue("qsyrusri.receiver.bytesAvailable");
System.out.println(" Bytes available: " + value);
value = pcml.getValue("qsyrusri.receiver.userProfile");
System.out.println(" Profile name: " + value);
value =
pcml.getValue("qsyrusri.receiver.previousSignonDate");
System.out.println(" Previous signon date:" + value);
value =
pcml.getValue("qsyrusri.receiver.previousSignonTime");
System.out.println(" Previous signon time:" + value);
}
}
catch (PcmlException e)
{
System.out.println(e.getLocalizedMessage());
e.printStackTrace();
System.out.println("*** Call to QSYRUSRI failed. ***");
System.exit(0);
}
System.exit(0);
} // End main()
}
**********************************************************
PCMLDOCUMENT:
**********************************************************
<pcml version="1.0">
<!-- PCML source for calling "Retrieve user Information" (QSYRUSRI) API -->
<!-- Format USRI0150 - Other formats are available -->
<struct name="usri0100">
<data name="bytesReturned" type="int" length="4"
usage="output"/>
<data name="bytesAvailable" type="int" length="4"
usage="output"/>
<data name="userProfile" type="char" length="10"
usage="output"/>
<data name="previousSignonDate" type="char" length="7"
usage="output"/>
<data name="previousSignonTime" type="char" length="6"
usage="output"/>
<data type="byte" length="1"
usage="output"/>
<data name="badSignonAttempts" type="int" length="4"
usage="output"/>
<data name="status" type="char" length="10"
usage="output"/>
<data name="passwordChangeDate" type="byte" length="8"
usage="output"/>
<data name="noPassword" type="char" length="1"
usage="output"/>
<data type="byte" length="1"
usage="output"/>
<data name="passwordExpirationInterval" type="int" length="4"
usage="output"/>
<data name="datePasswordExpires" type="byte" length="8"
usage="output"/>
<data name="daysUntilPasswordExpires" type="int" length="4"
usage="output"/>
<data name="setPasswordToExpire" type="char" length="1"
usage="output"/>
<data name="displaySignonInfo" type="char" length="10"
usage="output"/>
</struct>
<!-- Program QSYRUSRI and its parameter list for retrieving USRI0100
format -->
<program name="qsyrusri" path="/QSYS.lib/QSYRUSRI.pgm">
<data name="receiver" type="struct" struct="usri0100"
usage="output"/>
<data name="receiverLength" type="int" length="4"
usage="input" />
<data name="format" type="char" length="8"
usage="input" init="USRI0100"/>
<data name="profileName" type="char" length="10"
usage="input" init="*CURRENT"/>
<data name="errorCode" type="int" length="4"
usage="input" init="0"/>
</program>
</pcml>
**********************************************************
ERROR WHILE RUNNING THE JAVAPGM:
**********************************************************
D:\ClipperJavaApps\resources>java qsyrusri
Beginning PCML Example..
Constructing ProgramCallDocument for QSYRUSRI API...
Exception in thread "main" java.util.MissingResourceException: PCML document
source 'qsyrusri' cannot be found.
at
com.ibm.as400.data.SystemResourceFinder.getPCMLDocument(SystemResourceFinder
.java:196)
at com.ibm.as400.data.PcmlSAXParser.<init>(PcmlSAXParser.java:98)
at
com.ibm.as400.data.ProgramCallDocument.loadSourcePcmlDocument(Program
CallDocument.java:1076)
at
com.ibm.as400.data.ProgramCallDocument.loadPcmlDocument(ProgramCallDocument.
java:979)
at
com.ibm.as400.data.ProgramCallDocument.<init>(ProgramCallDocument.java:127)
at qsyrusri.main(qsyrusri.java:38)
**********************************************************
ERROR WHILE TRYING TO SERIALIZE THE PCML-DOCUMENT:
**********************************************************
D:\ClipperJavaApps\resources>java
com.ibm.as400.data.ProgramCallDocument -serialize qsyrusri
Exception in thread "main" java.util.MissingResourceException: PCML document
source 'qsyrusri' cannot be found.
at
com.ibm.as400.data.SystemResourceFinder.getPCMLDocument(SystemResourceFinder
.java:196)
at com.ibm.as400.data.PcmlSAXParser.<init>(PcmlSAXParser.java:98)
at
com.ibm.as400.data.ProgramCallDocument.loadSourcePcmlDocument(Program
CallDocument.java:1076)
at
com.ibm.as400.data.ProgramCallDocument.main(ProgramCallDocument.java:237)