Example 6: Using the Simple File Target Connector

This section describes how to use the simple file target connect to:

  • Write PeopleSoft data to a file.

  • Read data into PeopleSoft from a file.

This section describes how to use the simple file target connector to write PeopleSoft data to a file.

To write data to a file:

  1. In PeopleSoft Application Designer, open the EXAMPLE_WORKREC record. 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("TestNode");
    &descNode.NodeValue = "This message was written to a file.";
    
    /* put the XML in the request... */
    &msg.setxmldoc(&xmlDoc);
    
    /* ...and send */
    &response = %IntBroker.SyncRequest(&msg);
    
  2. In the PeopleSoft Pure Internet Architecture, open the node definition TARGETNODE.

    1. On the Node Definitions-Connectors tab, set the Connector ID to FILEOUTPUT.

    2. Add the following connector properties and values:

      Property

      Value

      Method

      PUT

      FilePath

      Enter the location where you want the connector to write the file. For example, c:\temp.

  3. Access the integrationGateway.properties file and comment out the following line.

    ig.fileconnector.password=EncryptedPassword

    The password option is not used in this example.

  4. In the PeopleSoft Pure Internet Architecture, open the EXAMPLE_PAGE page and click Test.

  5. Go to the directory specified in the connector properties, and open the new file. The contents should reflect what was created in the PeopleCode.

This section describes how to use the simple file target connector to read data into PeopleSoft from files.

To read data from files into PeopleSoft:

  1. Create an XML file and include the following text:

    <?xml version='1.0'?> 
    <ConnectorTest>
      <TestNode>
        The file has been read from the file system.
      </TestNode>
    </ConnectorTest>
    
  2. In PeopleSoft Application Designer, open the EXAMPLE_WORKREC record. 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 results */
    &xmlDoc = &response.getxmldoc();
    MessageBox(0, "", 0, 0, &xmlDoc.genxmlstring());
    
  3. In the PeopleSoft Pure Internet Architecture, open the TARGETNODE node definition.

    1. Set the Connector ID to FILEOUTPUT.

      Set the FilePath property to the location from where the connector will read the output file.

    2. Add the following connector properties and values:

      Property

      Value

      FileName

      Specify the name of the output file. The file's default name has the following format: sourcenodename.serviceoperationname.publication_id.xml

      METHOD

      GET

  4. Access the integrationGateway.properties file and comment out the following line.

    ig.fileconnector.password=EncryptedPassword

    The password option is not used in this example.

  5. In the PeopleSoft Pure Internet Architecture, open the EXAMPLE_PAGE page and click the Test button.

    A message box appears that displays the data from the file read.