8 Replies Latest reply: Jul 25, 2007 9:07 PM by Jacob Ellsworth RSS

Is there a simple way to HTTP Post a flat file?

Jay Malla
Currently Being Moderated

Is there a simple way to http post a flat file?

 

The scenario -

We are invoking an ABAP client proxy that sends data to XI which maps the data to an xml file which represents the flatfile data.

 

The issue - I can generate the flat file through the file adapter receiver specifying file content conversion and giving it the fieldFixedLengths.  But I have no option to do this in the HTTP adapter receiver.

 

What I am attempting to do is to pick up the flatfile generated through the file adapter in a temporary file location as a binary file, send it through an non-existent interface (not defined in the Repository but just made up) and then post this content to the HTTP destination.  I am able to pick up the flatfile and route it all the way through to the HTTP receiver sender channel.  I am getting an error at that point - but I am not sure if this is because i am just posting it to the XI integration server temporarily (the partner's URL is not available yet).  

 

I am not sure if this is a good approach.  Is there a simple way to do this without developing any custom code?

 

Regards,

Jay Malla

SAP XI Consultant

Licensed To Code

  • Re: Is there a simple way to HTTP Post a flat file?
    Jay Malla
    Currently Being Moderated

    I get this error though - which is probably from the HTTP adapter not being able to read in the data to post... but i am not sure...

     

     

     

      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

    - <!--  Call Adapter

      -->

    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">

      <SAP:Category>XIAdapter</SAP:Category>

      <SAP:Code area="PLAINHTTP_ADAPTER">ATTRIBUTE_SERVER</SAP:Code>

      <SAP:P1>500</SAP:P1>

      <SAP:P2>Internal Server Error</SAP:P2>

      <SAP:P3>Error during parsing of SOAP header</SAP:P3>

      <SAP:P4 />

      <SAP:AdditionalText />

      <SAP:ApplicationFaultMessage namespace="" />

      <SAP:Stack>Http server code 500 reason Internal Server Error explanation Error during parsing of SOAP header</SAP:Stack>

      <SAP:Retry>M</SAP:Retry>

      </SAP:Error>

  • Re: Is there a simple way to HTTP Post a flat file?
    Stefan Grube
    Currently Being Moderated

    You can use the SOAP adapter. Check the flag <i>Do Not Use SOAP Envelope</i>.

    You can use the content conversion module <i>MessageTransformBean</i>

     

    I do not know, why your scenario does not work. Maybe you check the content type and the charset.

     

    Regards

    Stefan

    • Re: Is there a simple way to HTTP Post a flat file?
      Jay Malla
      Currently Being Moderated

      Hi Stefan,

       

      Thanks for the suggestion.  I will try it out.  Is there anyway to simulate posting a file to a web server as html form file field?

       

      Regards,

      Jay

      • Re: Is there a simple way to HTTP Post a flat file?
        Vinodh Damodharan
        Currently Being Moderated

        Hi Jay,

         

        Use the HTTP Client to post messages to XI server.

        You can get sample code for a http client from:

        /message/266750#266750 [original link is broken]

         

         

        All U need is to paste the xml file that you want to send to XI.

         

        Regards,

        Vinodh

      • Re: Is there a simple way to HTTP Post a flat file?
        Stefan Grube
        Currently Being Moderated

        I don't think, that is a good integration scenario to simulate HTML forms. What about error handling?

         

        Technically I see no problem. When you know the URL and the structure of the call (you might use an HTTP sniffer to get the information).

         

        Stefan

        • Re: Is there a simple way to HTTP Post a flat file?
          Jay Malla
          Currently Being Moderated

          Hi Stefan,

           

          Thanks for the feedback.  The issue is that the partner site allows us to upload the file via a html page with a form file input.  We are trying to simulate that through XI.  The partner has not created a webservice that accepts the flat file posting (ideally xml would be better and they could just convert it to flat file themselves).  But we're working under certain constraints.

           

          So for now, we need to simulate posting using a web page with the file input field.  So though I can post the flat file based on your suggestion of using the SOAP adapter and stripping out the SOAP envelope, i am not sure I can simulate the http form post which passes the necessary http header information (input type="file") :

           

          Content-Disposition: form-data; name="files"; filename="file1.txt"

          Content-Type: text/plain

           

           

           

           

          Here is some notes regarding posting file data from HTML pages:

          http://www.w3.org/TR/REC-html40/interact/forms.html

           

          ... The following example illustrates "multipart/form-data" encoding. Suppose we have the following form:

           

          <FORM action="http://server.com/cgi/handle"

                 enctype="multipart/form-data"

                 method="post">

             <P>

             What is your name? <INPUT type="text" name="submit-name"><BR>

             What files are you sending? <INPUT type="file" name="files"><BR>

             <INPUT type="submit" value="Send"> <INPUT type="reset">

          </FORM>

           

           

          If the user enters "Larry" in the text input, and selects the text file "file1.txt", the user agent might send back the following data:

           

             Content-Type: multipart/form-data; boundary=AaB03x

           

             --AaB03x

             Content-Disposition: form-data; name="submit-name"

           

             Larry

             --AaB03x

             Content-Disposition: form-data; name="files"; filename="file1.txt"

             Content-Type: text/plain

           

             ... contents of file1.txt ...

             AaB03x

           

          If the user selected a second (image) file "file2.gif", the user agent might construct the parts as follows:

           

             Content-Type: multipart/form-data; boundary=AaB03x

           

             --AaB03x

             Content-Disposition: form-data; name="submit-name"

           

             Larry

             --AaB03x

             Content-Disposition: form-data; name="files"

             Content-Type: multipart/mixed; boundary=BbC04y

           

             --BbC04y

             Content-Disposition: file; filename="file1.txt"

             Content-Type: text/plain

           

             ... contents of file1.txt ...

             --BbC04y

             Content-Disposition: file; filename="file2.gif"

             Content-Type: image/gif

             Content-Transfer-Encoding: binary

           

             ...contents of file2.gif...

             BbC04y

             AaB03x

           

           

           

          Thanks for your help.  I appreciate it.

           

          Regards,

          Jay

Actions