Example 7: Using the FTP Target Connector
This sections discusses how to use the FTP target connector to:
Upload files to an FTP server.
Download files from an FTP server.
For the examples presented in this section, you must have an active FTP server, as well as an account on that server.
To upload a file to an FTP server:
In PeopleSoft Application Designer, open the EXAMPLE_WORKREC record and add the following PeopleCode to the FieldChange event for the TEST field:
&msg = CreateMessage(Operation.EXAMPLE_SERVICE_OPR); &xmldata = "<?xml version='1.0'?><ConnectorTest/>"; /* create an XmlDoc */ &xmlDoc = CreateXmlDoc(&xmldata); &rootNode = &xmlDoc.documentelement; &descNode = &rootNode.addelement("FTPtest"); &descNode.nodevalue = "This text will be uploaded"; /* put the XML in the message */ &msg.setxmldoc(&xmlDoc); /* send the request */ &response = %IntBroker.SyncRequest(&msg);
In the PeopleSoft Pure Internet Architecture, open the TARGETNODE node definition.
On the Node Definitions-Connectors tab, set the Connector ID to FTPTARGET.
Set the following properties to the values indicated:
Property
Value
HOSTNAME
Specify the IP address or name of the FTP server for the connection.
METHOD
PUT
USERNAME
Enter the FTP server login ID.
PASSWORD
Enter the password for the login to the FTP server. This password must be encrypted. Use the Password Encryption Utility at the bottom of the page to encrypt the password, if necessary
In the PeopleSoft Pure Internet Architecture, open the EXAMPLE_PAGE page and click the Test button.
Login to the FTP server and check for the file. Open the file and verify the contents.
To download a file from an FTP server:
Create an XML file with the following contents and place the file on an FTP server.
<?xml version="1.0"?> <ConnectorTest> <TestNode>This message will be downloaded from an FTP server.</TestNode> </ConnectorTest>
In PeopleSoft Application Designer, open the EXAMPLE_WORKREC record and add the following PeopleCode to the FieldChange event for the TEST field:
&msg = CreateMessage(Operation.EXAMPLE_SERVICE_OPR); &xmldata = "<?xml version='1.0'?><ConnectorTest/>"; /* create an XmlDoc */ &xmlDoc = CreateXmlDoc(&xmldata); /* put the XML in the message */ &msg.setxmldoc(&xmlDoc); /* send the request */ &response = %IntBroker.SyncRequest(&msg); /* display the contents */ &xmlDoc = &response.getxmldoc(); MessageBox(0, "", 0, 0, &xmlDoc.genxmlstring());
In the PeopleSoft Pure Internet Architecture, open the TARGETNODE node definition.
On the Node Definitions-Connectors tab, set the Connector ID to FTPTARGET.
Set the following properties to the values indicated:
Property
Value
HOSTNAME
Specify the IP address or name of the FTP server for the connection.
METHOD
GET
FILENAME
Specify the name of the file.
USERNAME
Enter the FTP server login ID.
PASSWORD
Enter the password for the login to the FTP server. This password must be encrypted. Use the Password Encryption Utility at the bottom of the page to encrypt the password, if necessary
In the PeopleSoft Pure Internet Architecture, open the EXAMPLE_PAGE page and click the Test button.
The contents of the XML file will display in the message box.