[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Posting MultPart Mime



   Richard,

   if your xml-files looks like the following you can't do a raw
   concatination because

   only one root element is allowed in XML:

   <?xml version="1.0" encoding="UTF-8"?> � � � � � � � �   <orders> � � � � � � � � � � � � � � � � � � � � �   � �   �<order refnum="1234567" tax="0.0" total="50.0"> � � �   � <date>2011-03-20</date> � � � � � � � � � � � � � ��   � <address> � � � � � � � � � � � � � � � � � � �   � ��   � �<name>Patricia DiMascio</name> � � � � � � � � � ��   � �<street1>6 Jamie Drive</street1> � � � � � � � � ��   � �<street2 /> � � � � � � � � � � � � � � � � � �   � �   � �<street3 /> � � � � � � � � � � � � � � � � � �   � �   � �<city>Johnston</city> � � � � � � � � � � � � � � �   � �<state>RI</state> � � � � � � � � � � � � � � � �   �   � �<zip>02919</zip> � � � � � � � � � � � � � � � �   ��   � �<country>United States of America (U.S.A)</country>
   � �<email /> � � � � � � � � � � � � � � � � � � �   � �   � �<phone>[1](401)-942-2604</phone> � � � � � � � � � � �   � </address> � � � � � � � � � � � � � � � � � � �   � �   �</order> �   </orders> � ��   or
   ��<order refnum="1234567" tax="0.0" total="50.0"> � � �   � <date>2011-03-20</date> � � � � � � � � � � � � � ��   � <address> � � � � � � � � � � � � � � � � � � �   � ��   � �<name>Patricia DiMascio</name> � � � � � � � � � ��   � �<street1>6 Jamie Drive</street1> � � � � � � � � ��   � �<street2 /> � � � � � � � � � � � � � � � � � �   � �   � �<street3 /> � � � � � � � � � � � � � � � � � �   � �   � �<city>Johnston</city> � � � � � � � � � � � � � � �   � �<state>RI</state> � � � � � � � � � � � � � � � �   �   � �<zip>02919</zip> � � � � � � � � � � � � � � � �   ��   � �<country>United States of America (U.S.A)</country>
   � �<email /> � � � � � � � � � � � � � � � � � � �   � �   � �<phone>[2](401)-942-2604</phone> � � � � � � � � � � �   � </address> � � � � � � � � � � � � � � � � � � �   � �   �</order> �   �� � � � � � � � � � � � � � � � � �
   So you have to extract data from the two xml-files and create a�
   new XML file.

   I don't know if Scott has some tool for that, but otherwise I have�
   subprocedures�in powerEXT Core that can do the job quite easily.

   On Tue, Dec 6, 2011 at 3:50 PM, Richard Medders
   <[3]richard@xxxxxxxxxxxx> wrote:

     Thanks for the insight!
     So, with that in mind, I have 2 separate xml documents that I need
     to
     combine into 1 before I send it.... does httpapi have any tool that
     will
     accomplish that?
     Richard Medders
     Cleveland, MS�     [4]662-846-5653�direct
     [5]662-588-4521�Cell

   -----Original Message-----
   From: Scott Klement [mailto:[6]sk@xxxxxxxxxxxxxxxx]
   Sent: Monday, December 05, 2011 3:47 PM
   To: HTTPAPI and FTPAPI Projects
   Subject: Re: Posting MultPart Mime
   hi Richard,
   > Can anyone give me advice on how to post a multipart mime document
   (aka
   > ebxml or soap with attachment)?
   HTTPAPI does not have tools for building/formatting a MIME document.
   You will have to create/format that document yourself. �Once created,
   HTTPAPI can send it.
   > So, I need to insert the http headers, including total bytes as
   Content
   > Length, then insert the soap doc, then insert a mime break, then
   insert
   > the payload doc, then insert final mime break. �Here is a sample of
   > what it should look like.
   HTTPAPI is going to take care of the HTTP keywords for you -- but it
   won't take care of the MIME keywords or MIME formatting.
   In your example, these are the HTTP keywords:
   �POST /rich HTTP/1.1
   �Connection: close
   �Cache-control: no-cache
   �SOAPAction: "ebXML"
   �Host: 172.16.16.10
   �Content-Type: multipart/related; type="text/xml"
   start="20111205094816.header"; boundary="---ZMODEDI??gc0p4Jq0M2Yt50001"
   �Content-Length: 8740
   HTTPAPI will automatically take care of all of those for you. �It will
   calculate the content-length from the length of the data you pass to
   it.
   The values for the Content-Type and SoapAction fields are provided in
   parameters that you pass to HTTPAPI.
   Note that in older versions of HTTPAPI, the Content-Type and SoapAction
   keywords were limited to shorter (64 char) variables. �In the current
   BETA of HTTPAPI, they allow up to 16k. �So if the size of the
   parameters
   isn't long enough in the copy you're using, please update to the one
   here:
   [7]http://www.scottklement.com/httpapi/beta
   With those tips in mind, you should be able to call
   http_url_post_stmf()
   to send the document (provided that it's formatted properly.)
   Good luck
   -----------------------------------------------------------------------
   This is the FTPAPI mailing list. �To unsubscribe, please go to:
   [8]http://www.scottklement.com/mailman/listinfo/ftpapi
   -----------------------------------------------------------------------

   --
   Regards,
   Henrik Rützou
   �   [9]http://powerEXT.com
   �   [plogofull200.png]

References

   1. tel:%28401%29-942-2604
   2. tel:%28401%29-942-2604
   3. mailto:richard@xxxxxxxxxxxx
   4. tel:662-846-5653
   5. tel:662-588-4521
   6. mailto:sk@xxxxxxxxxxxxxxxx
   7. http://www.scottklement.com/httpapi/beta
   8. http://www.scottklement.com/mailman/listinfo/ftpapi
   9. http://powerext.com/
      /copy qsrc,pxapihdr      General H-Spec's

      * powerEXT Service Program Connector
      /copy qsrc,pxapicgicn    Basic HTTP connecter & Productivity Services

      * Support for HTTPAPI by Scott Klement
      /copy qrpglesrc,httpapi_h

      * Declare Internal Variables
     d i               s             10i 0
     d store           s             10i 0
     d xmlFile         s            256a   varying
     d tmpFile         s            256a   varying

      /free
       // Clear powerEXT Service Program & Responce Object
       clearSrvPgm();

       // Create a Store and XML header and add root elements in it
       store = storeNew();
       storeInz(store);
       storeAppendText(store:'<?xml version="1.0" encoding="UTF-8"?>');
       storeAppendText(store:nl);
       storeAppendText(store:'<orders>');
       storeAppendText(store:nl);

       // Initialize the xmlReader
       for i = 1 to 2;
       if i = 1;
         xmlFile = '/order1234567.xml';
       endif;
       if i = 2;
         xmlFile = '/order5555999.xml';
       endif;

       // initialize the XML reader
       xmlFromStmf(xmlFile);
       xmlReaderInz(xmlAddr:xmlSize:*off:*on);
       xmlReaderCase('L');

       // Read the XML
       dow xmlReader = 0;
         select;

           // at end of the order append it to the store
           when xmlGetNode = '/order';
             storeAppendText(store:x'05');
             storeAppend(store:xmlAddrOuter:xmlSizeOuter);
             storeAppendText(store:nl);
             leave;

         endsl;
       enddo;

       xmlFree();
       endfor;

       // end and save the XML
       storeAppendText(store:nl);
       storeAppendText(store:'</orders>');
       tmpFile = '/orderscat.xml';
       storeToStmf(store:tmpFile:1208);

       // send the XML file or the store directly with HTTPAPI


       storeFree(store);

       *inlr = *on;
      /end-free
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------