Wednesday, September 16, 2009

PeopleSoft PeopleCode XMLDoc

Generating XML with namespace prefixes using PeopleCode XMLDoc object.

-

It may sound stupid but we do this by adding the xmlns as an attribute to the required element. Off course against the XML specs, which clearly says that we should never treat xmlns as an attribute.

-

   Required XML (sample):

        <?xml version="1.0"?>
        <q0:bibliograpphy xmlns:q0="
http://example.org">
          <q0:book>
            <q0:title>TCP/IP Illustrated</q0:title>
            <q0:publisher>Addison-Wesley</q0:publisher>
            <price>65.95</price>
          </q0:book>
        </q0:bibliograpphy>

-

-

    PeopleCode

        Local XmlDoc &reqXML = CreateXmlDoc("");
        Local XmlNode &root = &reqXML.CreateDocumentElement("q0:bibliograpphy", "
http://example.org");
       &root.AddAttribute("xmlns:q0", "http://example.org");
        Local XmlNode &book = &root.AddElement("q0:book");
        Local XmlNode &temp = &book.AddElement("q0:title").AddText("TCP/IP Illustrated");
        &temp = &book.AddElement("q0:publisher").AddText("Addison-Wesley");
        &temp = &book.AddElement("price").AddText("65.95");

        Local File &file = GetFile("<SOME_PATHTest>/XMLDoc.xml", "W", %FilePath_Absolute);
        &file.WriteLine(&reqXML.GenFormattedXmlString());

-

-

-

-

FTP using PeopleCode PutAttachment() inside App Engine

-

The return code (%Attachment_FileNotFound)  from PutAttachment() PeopleCode built-in function was incorrect.
Internally, it was failing as Write Access was revoked on the FTP server (ftp://username:password@hostname/AEI/SAKAI/)
This FTP server is running on some Windows Server 2008 machine and we need to contact the owner to get the write access.
Here's the ftp log generated from PutAttachment() PeopleCode.

verbose on
bin
200 Type set to I.
mkdir AEI
550 AEI: Cannot create a file when that file already exists.
cd AEI
250 CWD command successful.
mkdir SAKAI
550 SAKAI: Cannot create a file when that file already exists.
cd SAKAI
250 CWD command successful.
Local directory now C:\.
Local directory now C:\Documents and Settings.
Local directory now C:\Documents and Settings\BJETHWAN.PEOPLESOFT.
Local directory now C:\Documents and Settings\BJETHWAN.PEOPLESOFT\Local Settings.
Local directory now C:\Documents and Settings\BJETHWAN.PEOPLESOFT\Local Settings\Temp.
lcd C:\
lcd DOCUME~1
lcd BJETHW~1.PEO
lcd LOCALS~1
lcd Temp
put "bin.xml" "bin.xml"
200 PORT command successful.
550 bin.xml: Access is denied.


-

And here's the output from command line

-

C:\>bin.xml
C:\>ftp 10.138.125.144
Connected to 10.138.125.144.
220 Microsoft FTP Service
User (10.138.125.144:(none)): ftpuser1
331 Password required for ftpuser1.
Password:
230 User ftpuser1 logged in.
ftp> put bin.xml bin.xml
200 PORT command successful.
550 bin.xml: Access is denied.
ftp> cd AEI
250 CWD command successful.
ftp> cd SAKAI
250 CWD command successful.
ftp> delete READGROUPSFROMSAVEPOINT.xml
550 READGROUPSFROMSAVEPOINT.xml: Access is denied.
ftp> bye
C:\>

-

-

Basic FTP Commands

http://www.cs.colostate.edu/helpdocs/ftp.html