AJAX HTTP Posts:  No Response problem (PT5)

To avoid cross-scripting popups and such I am posting to the gateway'ed address. I am still a bit new to PT so forgive me if I am calling this URL something else. (space in http to avoid linking). Making a 'GET' request works like a champ with this URL. Working outside of the portal will also result in much success. But within the portal and making a 'POST' request 'myDiv' never sees content. It seems as if the readystate never gets to 4 -- only 3. Any help?
MY CODE:url = 'h ttp://myPortalServer/portal/server.pt/gateway/PTARGS_0_123_123_0_0_123/https;/myGadgetServer;443/myApp/myForm.htm';
postVars = 'var1=123&var2=123';
target = document.getElementById('myDiv');
http_request.onreadystatechange = processContents;http_request.open('POST', url, true);http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length", postVars.length);http_request.setRequestHeader("Connection", "close");http_request.send(postVars);
function processContents() {if (http_request.readyState == 4) {target.innerHTML = http_request.responseText;}}

A little trial-n-error and solved my own problem. Just removed this line and all works fine. Interesting...
http_request.setRequestHeader("Connection", "close");
vr, Rich

Similar Messages

  • HTTP POST to PHP server problem

    Hi, im trying post a long string to php from a MIDLET, but i have some problems. When i send the whole String, my php server cant receive the request (i have not any response), but, if the string that i send is 1/5 from the original, the process is successful correctly. have somebody any idea?
    thx

    this is my problem, extracted from another topic on this forum:
    "Hi everyone.
    I have a problem, and hope someone may help me.
    My midlet is uploading sizeable data via http POST.
    I'm using WTK104, since i need MIDP1.0
    The code have been tried on DefaultGrayPhone emulator
    and add-on Nokia's Series 60 Emulator.
    Both emulators chunck data, however in different ways.
    Deafult one simply produces wrong chunk length (possibly a bug),
    Nokia's one always chunks by equal offsets of 2016 bytes.
    I'm not using flushing, just close. All the data is being send
    at once by one output stream write call.
    So I believe (after proper investigation) that MIDP will use chunked Transfer-Encoding method whatever
    on such sizeable a data as mine is (up to 50KB) and there's no way to override this behaviour.
    Here the main problem appears - Apache refuses to accept chunked encoding in request. The corresposnding message is given in error log
    *chunked transfer encoding forbidden*. The returned code is 411 - Content-Length requred. I see no way to override this behaviour of Apache. I was trying to upload my data into Zope web-server, which is my primary goal, but it doesn't handle chunked request either.
    Has anyone faced the same problem? Who has managed to POST sizeable data from midlet? Which web servers did you use for that?
    Any inputs are highly appreciated!
    Anton"
    Another:
    "> So I believe (after proper investigation) that MIDP
    will use chunked Transfer-Encoding method whatever
    on such sizeable a data as mine is (up to 50KB) and
    there's no way to override this behaviour.Is this true? When I try to set the content-length headers and then write a large byte[] to the output stream I got from an HttpConnection, the HttpConnection appears to remove the content-length header altogether and automatically sets the transfer-encoding to chunked.
    Note- I am not calling flush on the outputstream, but I am calling httpconnection.getResponseCode, which I believe calls flush on the outputstream.
    Abraham"
    I have the identical problem.

  • Applicatio​n using Http Post... getting error response

    Im from Ecuador, and me and other 4 people from the same country are getting this error response when a native java application is trying to make a http post to mydomain.com
    The requested URL could not be retrieved:
    While trying to process the request:
    POST /somedir/more?var1=abc&var2=xyz& HTTP/1.1
    Expect: 100-continue
    Host: mydomain.com
    Content-Length: 40
    Content-Type: text/plain; charset=utf-8
    Accept: */*
    Connection: close
    Invalid request. Some aspect of the HTTP Request is nivalid. Possible problems:
    Missing or unknwon request method
    Missing URL
    Missing HTTP Identifier (HTTP/1.0)
    Request is too large
    Content-Length missing for POST or PUT request
    Generated by Blackberry.Internet.Browsing.Service (squd/2.7.STABLE6)
    This issue is only happening in my country (Ecuador). I have some friends in Argentina and they have no problems at all. What are the posible causes for this problem?
    Message Edited by andufo on 07-09-2009 08:43 PM

    Hi again,
    im attaching all the info you request:
    What does the program actually do?
    Social network (because of the TOS of this forum im not allowed to post project names or urls)
    What is it trying to send when you submit a request?
    What url is it posting the information to? 
    Im attaching all this at the end of the post.
    Is it the 'exact' same application that works in other countries?
    Yeap, the exact same one...
    Is it supposed to be useing the Internet Browser?
    No, it is a native app. The Browser is not used at all.
    Are you on a BlackBerry Enterprise Server? 
    Im on BIS, all the users use BIS.
    Technical details:
    1) The app makes an Http Connection (POST) to:
    http://mydomain.com/api/call?param1=abc&param2=xyz
    2) This is the Http connection configuration:
    httpConnection = (HttpConnection) Connector.open(url);
    HttpConnection.POST;
    ("Content-Type", "text/plain; charset=utf-8");
    ("Host", 'mydomain.com');
    ("Content-Length", 100); //depends on sent data
    ("User-Agent", 'BlackBerry8300... etc');
    ("Expect", "100-continue");
    3) On every country it works fine... on my country i get this error:
    The requested URL could not be retrieved while trying to process the request:
    POST /app/llamada?param1=abc&param2=xyz& HTTP/1.1
    - Expect: 100-continue
    - Host: mydomain.com
    - Content-Length: 100
    - Content-Type: text/plain; charset=utf-8
    - Accept: */*
    - Connection: close
    Invalid request. Some aspect of the HTTP Request is invalid. Possible problems:
    - Missing or unknwon request method
    - Missing URL
    - Missing HTTP Identifier (HTTP/1.0)
    - Request is too large
    - Content-Length missing for POST or PUT request
    Generated by Blackberry.Internet.Browsing.Service (squid/2.7.STABLE6)

  • How to send te XML data using HTTPS post call & receiving response in ML

    ur present design does the HTTP post for XML data using PL/SQL stored procedure call to a Java program embedded in Oracle database as Oracle Java Stored procedure. The limitation with this is that we are able to do HTTP post; but with HTTPS post; we are not able to achieve because of certificates are not installed on Oracle database.
    we fiond that the certificates need to be installed on Oracle apps server; not on database server. As we have to go ultimately with HTTPS post in Production environment; we are planning to shift this part of program(sending XML through HTTPS post call & receiving response in middle layer-Apps server in this case).
    how i can do this plz give some solution

    If you can make the source app to an HTTP Post to the Oracle XML DB repository, and POST contains a schema based XML document you can use a trigger on the default table to validate the XML that is posted. The return message would need to be managed using a database trigger. You could raise an HTTP error which the source App would trap....

  • Error while trying to get an HTTP POST response

    Hi everyone,
    I'm coding a simple client to download some information from a local machine in my LAN.
    I have to do this with an http post request.
    When i try to parse the http response the program catch an exception, this one:
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(...)
    the parameter is a JSON request, and of course the response is a JSON formatted.
    i put the http request code:
    import java.io.BufferedInputStream;
    import java.io.BufferedReader;
    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.net.HttpURLConnection;
    import java.net.URL;
    public class HttpDownloaderThread  extends Thread{
         private String url;
            private String param;
         private HttpDownloadListener listener;
         private HttpURLConnection connection=null;
         private InputStream is;
            private OutputStreamWriter wr;
         public HttpDownloaderThread(String _url,String param, HttpDownloadListener _listener){
              url = _url;
              listener = _listener;
                    this.param=param;
         public void run(){
              try{
                   connection=(HttpURLConnection)new URL(url).openConnection();
                            connection.setRequestMethod("POST");
                            connection.setReadTimeout(5000);
                            connection.setRequestProperty("Content-Type", "application/jsonrequest");
                            connection.setDoOutput(true);
                            wr = new OutputStreamWriter(connection.getOutputStream());
                            wr.write(param, 0, param.length());
                            wr.flush();
                            int responseCode=0;
                   System.out.println();
                            try{
                             responseCode= connection.getResponseCode();
                            }catch(Exception e){
                                e.printStackTrace();
                   if (responseCode == HttpURLConnection.HTTP_OK){
                        is = connection.getInputStream();
                                     BufferedReader rd = new BufferedReader(new InputStreamReader(is));
                                    String line;
                                    while ((line = rd.readLine()) != null) {
                                        System.out.println(line);
                        closeHttpConnection();
                        listener.resourceDownloaded(url, null);
                                else{
                                closeHttpConnection();
                                listener.downloadFailed(url, new Exception("Http error: " + Integer.toString(responseCode)));
              }catch(Exception e){
                   e.printStackTrace();
                   listener.downloadFailed(url, e);
              }finally{
         public void closeHttpConnection(){
              if (is != null){
                   try{
                        is.close();
                                    wr.close();
                   }catch (Exception e){
                   }finally{
                        is = null;
                                    wr=null;
              if (connection != null){
                   try{
                        connection.disconnect();
                   }catch (Exception e){
                   }finally{
                        connection = null;
    }there's someone who know's why??
    Thanks to everyone :)
    Thomas.

    Hi Vincent,
    according to your script,it seems like you are trying to connect to Exchange Online?
    If so these as to be installed on your computer:
    http://go.microsoft.com/fwlink/?LinkId=286152
    http://go.microsoft.com/fwlink/p/?linkid=236297
    Reboot and run this command as one line:
    Set-ExecutionPolicy RemoteSigned
    $LiveCred = Get-Credential
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $LiveCred -Authentication Basic -AllowRedirection
    $Import = Import-Pssession $Session -AllowClobber
    Import-Module MSOnline -verbose
    Connect-MSOLservice -Credential $LiveCred
    Hope this helped
    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you. Thank you! Off2work

  • Retrieve data/files fro HTTP POST request in On-Demand process

    Hello,
    I would like to integrate https://github.com/blueimp/jQuery-File-Upload to my APEX 4.2 application inside XE11g. I would like to use this kind of jQuery component, multiple file upload, use Drag & Drop, image resize, size limit, filter extensions etc...
    This jQuery component and also others javascript uploaders sends data files to some defined URL. Developer need to build some servlet, php script or something on server side that will read files from HTTP request and stores it somewhere.
    Do you know how to do it in APEX? How can I read data from HTTP POST request in PL/SQL? Now I can only call my On-Demand application process from javascript, but I am not able to read any data from HTTP POST in it.
    Can I do it in APEX, or using MOD_PLSQL?
    I would like to implement this:
    1) some javascript uploader will call some URL of my application and sends HTTP POST with data files
    2) I will read data files from HTTP POST and store them into database
    3) I will create some HTTP response for javascript uploader
    Thank you for some tips

    I know about that existing plugin " Item Plugin - Multiple File Upload"
    But I doesn't work in IE and has only basic features. Licence for commercial use is also needed. I would like to use some existing jQuery plugin. There are many of these plugins with nice features. And only one problem is that I need to create some server side process/servlet/script.. that can recieve HTTP request, get files from it and stores them into DB.

  • Not able to send message - http post from MII 12.1.4.53 to PI 7.1

    Hi ,
    Question
    u2022     Is there any configuration to set up in MII and PI to do posting to PI as a web service? If YES, please guide.
    Situation
    u2022     We are with MII version 12.1.4.53 and trying to send message through http post to PI 7.1 server.
    u2022     We are getting the following error HTTP 500 Internal Error Issue.
    u2022     However we are able to post messages from SOAPUI through the same URL and with the MII system which is running on version 12.1.6.91 and 12.1.9.116
    u2022     HTTP Response received as below points to PI Configuration issue.
    Error
        <SOAP:Fault>
          <faultcode>SOAP:Server</faultcode>
          <faultstring>Server Error</faultstring>
          <detail>
            <s:SystemError xmlns:s="http://sap.com/xi/WebService/xi2.0">
              <context>XIAdapter</context>
              <code>ADAPTER.JAVA_EXCEPTION</code>
              <text><![CDATA[
    com.sap.aii.af.service.cpa.CPAObjectNotFoundException: Couldn't retrieve inbound binding for the given P/S/A values: FP=senderService;TP=;FS=null;TS=;AN=null;ANS=null;
    thanks
    Rajesh

    Hi Anudeep,
    The question isNOT ABOUT the format of the URL which MII should use.
    Using the same URL we are able to post the message from other MII versions with in the landscape( MII version 12.1.6 and MII version12.1.9) and through SOAP UI.
    500 Internal server error Problem arises when the message is sent through the same URL from MII 12,1.4 Build(53) to PI 7.1 ( we tried https Post, XI Webservice, WebService action blocks)
    Question:
    Are thre any configuration settings specific to MII version12.1.4 Build 53 which needds to be set in MII to communicate to PI 7.1.
    Thanks
    Rajesh

  • How to send a String to a Servlet using a HTTP POST

    Well, I have designed a servlet that receives a HTTP POST, I was testing it using an HTML form to send (using POST) information, now, I have coded a Java App to send it a string, I don't know how to make the servlet recognize that info so it can make its work, I am posting both codes (Servlet & API) so anyone can guide me and tell me how and where to modify them
    Servlet:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class xmlwriter extends HttpServlet
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    ServletOutputStream salida = res.getOutputStream();
    res.setContentType("text/HTML");
    String cadena = req.getParameter("cadena");
    File f1 = new File ("c:/salida.xml");
    FileWriter out = new FileWriter(f1);
    f1.createNewFile();
    out.write(cadena);
    out.close();
    salida.println("OK");
    Now, the JAVA API is:
    import java.io.*;
    import java.net.*;
    public class HTTPSender {
    public static void main(String[] args) throws Exception {
    URL url1 = new URL
    ("http://localhost:8080/XMLSender/xmlwriter");//internal site
    URLConnection UrlConnObj1 = url1.openConnection();
    HttpURLConnection huc1 = (HttpURLConnection)UrlConnObj1;
    huc1.setRequestMethod("POST");
    huc1.setDoOutput(true);
    huc1.setDoInput(true);
    huc1.setUseCaches(false);
    huc1.setDefaultUseCaches(false);
    String cadena = ""
    + "<root>\n"
    + "<tlf>$TLF$</tlf>\n"
    + "<op>$OP$</op>\n"
    + "<sc>$SC$</sc>\n"
    + "<body>$BODY$</body>\n"
    + "</root>";
         PrintWriter out = new PrintWriter(huc1.getOutputStream());
    System.out.println("string="+cadena);
    out.write(cadena);
    out.close();
    I'm a JAVA newbie, so, maybe I'm getting a bad idea of what I need to do, anyway, every (detailed) help is welcome. What my servlet should do (and it doesn't when I send the message through the API) is to write a file with the info received.

    I'm not trying to send a string from a WEB Page, I'm tryring to send it using a JAVA program, I mean, using a HTTPSender, in fact, I already have made the code to do that:
    import java.io.*;
    import java.net.*;
    public class HTTPSender {
    public static void main(String[] args) throws Exception {
    try {
    String cadena = "Message to be written";
    // Send data
    URL url = new URL("http://localhost:8080/XMLSender/xmlwriter");
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(cadena);
    wr.flush();
    // Get the response
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
    // Process line...
    wr.close();
    rd.close();
    } catch (Exception e) {
    And modified my servlet so it can receive anything:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class xmlwriter extends HttpServlet
    public void service(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    ServletOutputStream salida = res.getOutputStream();
    res.setContentType("text/HTML");
    String cadena = req.toString();
    File f1 = new File ("c:/salida.xml");
    FileWriter out = new FileWriter(f1);
    f1.createNewFile();
    out.write(cadena);
    out.close();
    salida.println("OK");
    Now the problem is that, the servlet in fact DOES create the file, but....the file is empty, that means that no info is arriving to the servlet, why?, how should I send it then? I repeat FORGET about a Web Page Form, that is in the past and I don't need that.

  • How to make a HTTP Post request to a remote server ?

    Hi Guys,
    I'm new to java technology. I've a small problem with my code. All i need is to send a request to the remote server whose control is not at all in my hands with the POST method, which includes few of the parameters along with one of them is a xml formatted variable. The result of this request is an xml generated out which i want to fetch in my jsp code. I've tried it with the HTTPUrlConnection method and code for the same is below :
    <%
    try {
    String xmlString = "<FARES><AGENCY_ID>TFI</AGENCY_ID><DEP_CITY>NYC</DEP_CITY><ARR_CITY>LON</ARR_CITY><DEP_DATE>12</DEP_DATE><DEP_MONTH>DEC</DEP_MONTH><OWRT>RT</OWRT></FARES>";
    URL url = new URL("http://www.lowestairprice.com/Canada/mars.asp?WCI=Start&WCE=XMLFARES&reqMsg=Yes&");
    HttpURLConnection con = (HttpURLConnection)url.openConnection();
    con.setInstanceFollowRedirects(true);
    con.setFollowRedirects(true);
    con.setRequestMethod("POST");
    con.setDoOutput(true);
    out.println("Testing...");
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()));
    bw.write("xmltekst=" + xmlString);
    bw.flush();
    bw.close();
    BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String line = br.readLine();
    String result ="";
    while (line !=null) {
    result += line;
    line = br.readLine();
    br.close();
    out.println("Resultat: " + result);
    } catch(Exception exc) {
    exc.printStackTrace();
    out.println(exc);
    %>
    But when i run this on browser it gives me the following error.
    java.net.MalformedURLException: unknown protocol: https
    Now the response they provide is thrown back with the https protocol instead of the http. How can i fetch their response in my jsp code and store it in a local variable.
    If anybody can help me out in this, i would be thankful for the same.
    Thanking You,
    Rgds,
    Gaurav
    (Software Engineer)
    Ultra Infotech.

    Have you tried to use HttpsURLConnection instead ?

  • Submitting a PDF form via HTTP Post: Beginner's Questions

    Hi,
    I am completely new to PDF forms, so I have been finding the documentation and options overwhelming.
    I am hoping to get pointed to the documentation/tutorials/examples I really need.
    I would like to build a "proof of concept" for my boss.  I would like to include a screen in our Java ( JSP & Spring ) webapp where either a PDF form is embedded or is accessed via a link.
    I have
    Adobe Acrobat Distiller X standard license
    Adobe Acrobat X Standard
    Microsoft Office 2010
    I made a small, 3 field Microsoft Word form.  I then converted it via DIstiller into a PDF form.
    I then found this document about how to submit a PDF form to a server side component:
    http://acrobatusers.com/tutorials/form-submit-e-mail-demystified
    My big problem with this document it doesn't have an example nor an example showing what is going on in a full HTML page.   As I result I have some questions:
    Can I see such an example somewhere?
    Does the call to the javascript function doc.SubmitForm(urlToMyServerSideComponent) go in a script tag on the HTML page like other javascripts?
    Can I execute that submit function from an HTML button or do I need to put a "submit" button on the PDF form?
    Do I need Adobe LiveCycle in order to create a PDF form with a "submit" button?  Free versions?
    Can I send via HTTP POST ?
    Do I need Adobe LiveCycle to crate a PDF form with a digital signature?
    Is there a document/tutorial that fits where I am starting off from? ( Please no books, I am tyring to show my boss that this is something that can be done, in a reasonable amount of time, not time to get and go through a book ).
    Thanks in advance for any tips that get me pointed in the right direction
    Steve

    To answer some of your specific questions:
    2, 3. The submit form button needs to be on the PDF. You can either configure a Submit Form action or use the submitForm JavaScript method.
    4, 6: No to both questions. You can create the form in Acrobat. Such forms are knows as Acroforms, as opposed to XFA forms that are created with LiveCycle Designer. Acroforms have wider support.
    5: Yes, that's the method that's used when submitting to a web server. You have your choice of formats. The "HTML Form" option causes the form data to be submitted in the same format as an HTML form, so the same type of server-side code can be used to process the data. As Dave's tutorial shows, the server should return an FDF as the response, however, as opposed to HTML content.
    It's a mistake to try to embed the PDF in a web page. So much depends on the user's browser, PDF viewer, and how both are configured. PDF forms can be submitted directly from Adobe Reader/Acrobat, so it's not necessary for them to be viewed in a browser. Note that Adobe Reader for iOS/Android don't yet support submitting to a web server (apart from FormsCentral), but that's is supposedly being worked on.
    Since you mentioned digital signatures, be aware that for Reader users to be able to sign, the document has to be Reader-enabled, either with Acrobat Pro or LiveCycle Reader Extensions (which is not the same as LiveCycle Designer). Digital signatures in PDF forms are not yet supported on mobile devices. Also, you will want to submit the entire PDF, as opposed to just the form data, when submitting a digitally signed form.

  • Render html form & send forms's input values as params via HTTP POST

    Hello,
    I'm using appache commons http client to send HTTP post queries to a given url and receive HTTP response then process it.
    one of the requirements of my Application is the following: one of these HTTP Post requests is supposed to return an HTML form with different html types (text filed, text area etc..) that i will need to display in my swing application. one important requirement is that i can't know in advance what the html form field types will be.. it depends on a given parameters that my application send as part of HTTP Post method (using apache http client).
    I Longly searched for a simple solution to this problem . There are many solutions but each one has it's limitations :
    1-i can render the html form inside a JEditorPane .but how can I collect the user entered data inside JEditorPane ? i'm not sure this swing component offers the capability to detect its html contents and more it will be difficult to know what are the values entered by user inside html form rendered by JEditorPane.
    2-are there any Java Embedded browsers that offer some API to enable me detect the html form fields ,capture the data entered by user inside the html form ?
    3-the solution i currently opted for is : parse html & convert html form to swing dialog. currently this solution i use works well but the cost of implementing it is high : it involves difficult parsing logic. this makes me worried .I'm not sure if i'm now using the right & easiest solution.
    I need some advice on What is the simplest and clean solution to render a html form & yet be able to collect user entered inputs & send the user input values as params via java HTTP POST request ?

    dragzul wrote:
    In my opinion, your actual solution is what you need to do. You're trying to "merge" two different kinds of view. Actually, the "easiest" way may be: if you have your data to display, you decide to show it on html or swing.Yes i believe that my current solution may be the unique one for my special requirements. when doing research about this problem i found a multitude of java libraries to convert xml to swing (ex: www.swixml.org) .However i was surprised there are no java libraries to convert HTML forms to swing dialogs -as far as i know-. this is a bit strange. The Limitation is that the developers of the server API are not Java guys and are reluctant to use an xml format that i can easily convert to swing . probably they have their own reasons as they might be using the HTML Response for some other server side work. So I was obliged to deal with an HTML stream that i need to display in my client application and process its data. in my opinion the only way to do this is by developing a HTML form to swing converter package. that's what i did now. i was only worried if i'm complicating things and if there are some easier solutions to this issue.
    thanks

  • Manual HTTP POST from ABAP

    I'm trying to use a kind of botched web service implementation that doesn't come with a WSDL file - so, no generated proxy for me to use. It also needs me to send an XML file via an HTTP POST - not in a SOAP envelope. This presents a problem for me - understandably, this isn't part of WebAS 6.40's web services stuff.
    Does anyone know of a way of manually posting something via HTTP in ABAP? I'm sure there must be some function module or class that exposes that functionality - I just can't find it! Any ideas anyone?

    Hi,
    You can get some idea from following code for your requirment
    DATA: WA_DATA TYPE TSRCLIN,
          WA_RESULT TYPE TY_XML,
          WA_INV_REP TYPE TY_INV_REP,
          T_INV_REP TYPE TABLE OF TY_INV_REP,
          WA_ICA_REC_REP TYPE TY_ICA_REC_REP,
          T_ICA_REC_REP TYPE TABLE OF TY_ICA_REC_REP,
          T_RESULT TYPE T_XML,
          SOURCE_ITAB TYPE ABAP_TRANS_SRCBIND_TAB,
          SOURCE_WA   TYPE ABAP_TRANS_SRCBIND,
          WA_ZTICAUSER TYPE ZTICAUSER.
    DATA: XSLTP TYPE REF TO CL_XSLT_PROCESSOR,
          G_IXML TYPE REF TO IF_IXML,
          G_STREAM_FACTORY TYPE REF TO IF_IXML_STREAM_FACTORY,
          G_ENCODING TYPE REF TO IF_IXML_ENCODING,
          RESSTR TYPE REF TO IF_IXML_OSTREAM,
          HTTP_CLIENT TYPE REF TO IF_HTTP_CLIENT .
    DATA: SURL TYPE STRING.
    DATA: WF_PROXY TYPE STRING ,
          WF_PORT TYPE STRING,
          WF_USER TYPE STRING,
          WF_PASSWORD TYPE STRING,
          RLENGTH TYPE I,
          R_CODE TYPE SY-SUBRC,
          USERID1 TYPE CHAR32.
    CONSTANTS: ENCODING     TYPE STRING VALUE 'UTF-8',
               C_COMMA(1)               VALUE ',',
               C_AP(2)                  VALUE 'AP',
               C_AR(2)                  VALUE 'AR',
               C_CF(2)                  VALUE 'CF',
        CONV->READ( IMPORTING DATA = XMLSTRING LEN = LEN ).
        SPLIT XMLSTRING AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE T_DATA.
    * Read Header Information
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY SOURCE_SYSTEM_ID DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'SOURCE SYSTEM ID' OR SOURCE_SYSTEM_ID IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY DATE DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'DATE' OR DATE IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY TIME DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'TIME' OR TIME IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY CREATED_BY DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'CREATED BY' OR CREATED_BY IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY TYPE DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'TYPE' OR TYPE IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          CONDENSE TYPE.
          L_TYPE1 = REPGRP.
          L_TYPE2 = TYPE.
          TRANSLATE L_TYPE1 TO UPPER CASE.
          CONDENSE L_TYPE1.
          TRANSLATE L_TYPE2 TO UPPER CASE.
          CONDENSE L_TYPE2.
          IF L_TYPE1 NE L_TYPE2.
            IF L_TYPE2 = C_AP.
              CONCATENATE C_ERROR1_AP C_ERROR1
                          INTO STRERROR SEPARATED BY SPACE.
            ELSEIF L_TYPE2 = C_AR.
              CONCATENATE C_ERROR1_AR C_ERROR1
                          INTO STRERROR SEPARATED BY SPACE.
            ELSEIF L_TYPE2 = C_CF.
              CONCATENATE C_ERROR1_CF C_ERROR1
                          INTO STRERROR SEPARATED BY SPACE.
            ENDIF.
          ENDIF.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        DELETE T_DATA INDEX 1.
        LOOP AT T_DATA INTO WA_DATA.
          SPLIT WA_DATA AT ',' INTO WA_RESULT-FITF
                                    WA_RESULT-COUNTERPARTYFITF
                                    WA_RESULT-FUCA
                                    WA_RESULT-COUNTERPARTYFUCA
                                    WA_RESULT-RECONCILIATIONACCOUNT
                                    WA_RESULT-INDICATORCUSTOMERVENDOR
                                    WA_RESULT-INVOICENUMBER
                                    WA_RESULT-DOCUMENTDATE
                                    WA_RESULT-POSTINGDATE
                                    WA_RESULT-DUEDATE
                                    WA_RESULT-INVOICEAMOUNT
                                    WA_RESULT-INVOICECURRENCY
                                    WA_RESULT-REPORTINGAMOUNT
                                    WA_RESULT-REPORTINGCURRENCY
                                    WA_RESULT-INDICATOR
                                    WA_RESULT-CREATIONDATE
                                    WA_RESULT-CLEARINGDATE.
    * Validation of the Structure.                               
          WA_RESULT-SOURCESYSTEM = SOURCE_SYSTEM_ID.
          APPEND WA_RESULT TO T_RESULT.
          WA_INV_REP-INVOICEREPORT = WA_RESULT.
          WA_ICA_REC_REP-ICARECONCILIATIONREPORT = WA_INV_REP.
          WA_ICA_REC_REP-REPGRP = REPGRP.
          WA_ICA_REC_REP-NAMESPACE = C_STR.
          APPEND WA_ICA_REC_REP TO T_ICA_REC_REP.
        ENDLOOP.
        TRY.
            CREATE OBJECT XSLTP.
          CATCH CX_XSLT_EXCEPTION.
        ENDTRY.
        G_IXML = CL_IXML=>CREATE( ).
        G_STREAM_FACTORY = G_IXML->CREATE_STREAM_FACTORY( ).
    ****Create an Endcoding and Byte Order
        G_ENCODING = G_IXML->CREATE_ENCODING( CHARACTER_SET = ENCODING
          BYTE_ORDER = 0 ).
    *****Create Output Stream
        RESSTR =
            G_STREAM_FACTORY->CREATE_OSTREAM_XSTRING( CONTENT ).
    ****Set the Encoding into a stream
        RESSTR->SET_ENCODING( ENCODING = G_ENCODING ).
    * Prepare for Transformation
        SOURCE_WA-NAME = 'BSPXML'.
        GET REFERENCE OF T_ICA_REC_REP INTO SOURCE_WA-VALUE.
        APPEND SOURCE_WA TO SOURCE_ITAB.
        CLEAR XMLSTRING.
        CALL TRANSFORMATION Z_BSP_XSLT
        SOURCE (SOURCE_ITAB)
        RESULT XML XMLSTRING.
        IF SY-SUBRC <> 0.
          STRERROR = C_ERROR3.
        ENDIF.
        DATA: X1 TYPE STRING,
              X2 TYPE STRING.
    * Change encoding from UTF-16 to UTF-8
        SPLIT XMLSTRING AT 'utf-16' INTO X1 X2.
        CLEAR XMLSTRING.
        CONCATENATE X1 'UTF-8' X2 INTO XMLSTRING.
        select single * into WA_ZTICAUSER
        from ZTICAUSER.
        if sy-subrc <> 0.
          clear WA_ZTICAUSER.
        endif.
    SURL = 'http://XXXXXYYYYY:8050/sap/xi/adapter_plain?'.
        CONCATENATE SURL
         'namespace=' 'http%3A//XXXX.com/corp/sapbw/fi/ica/xi111fn1'
                    '&interface=' 'IOA_ICA_ReconciliationReport'
                    '&service=' 'Send_ICA_ReconciliationReport'
                    '&party=' 'ICA_ManualUpload'
                    '&agency='
                    '&scheme='
                    '&QOS=EO&sap-user='  WA_ZTICAUSER-USERID
                    '&sap-password=' WA_ZTICAUSER-PTEXT
                    '&sap-client=' '060'
                    '&sap-language=EN'
                    INTO SURL.
    * Test of XML file.
    *    navigation->set_parameter( name = 'xmlstring'
    *                               value = xmlstring ).
    *    navigation->goto_page( 'XMLTest.xml' ).
    * Navigation Code
        RLENGTH = STRLEN( XMLSTRING ).
        CL_HTTP_CLIENT=>CREATE_BY_URL( EXPORTING URL    = SURL
                                   IMPORTING CLIENT = HTTP_CLIENT ).
        CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING
            NAME  = 'Content-Type'
            VALUE = 'text/xml; charset=utf-8'.
        CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING
            NAME  = '~request_method'
            VALUE = 'POST'.
        CALL METHOD HTTP_CLIENT->REQUEST->SET_CDATA
          EXPORTING
            DATA   = XMLSTRING
            OFFSET = 0
            LENGTH = RLENGTH.
        HTTP_CLIENT->SEND( ).
        HTTP_CLIENT->RECEIVE( ).
        HTTP_CLIENT->RESPONSE->GET_STATUS( IMPORTING CODE = RLENGTH ).
        XMLSTRING = HTTP_CLIENT->RESPONSE->GET_CDATA( ).
        HTTP_CLIENT->CLOSE( ).
        IF RLENGTH = '200'.
          STRERROR = C_SUCCESS.
    * Update the information into the Table
          TRANSLATE SOURCE_SYSTEM_ID TO UPPER CASE.
          CONDENSE SOURCE_SYSTEM_ID.
          USERID1 = USERID.
          TRANSLATE USERID1 TO UPPER CASE.
          CONDENSE USERID1.
          CALL FUNCTION 'ZFM_BSP_ICA_UPLOAD'
            EXPORTING
              IV_SOURCE      = SOURCE_SYSTEM_ID
              IV_USERID      = USERID1
              IV_TYPE        = TYPE
    *          IV_UPLOAD_DATE = SY-DATUM
    *          IV_UPLOAD_TIME = SY-UZEIT
            IMPORTING
              R_CODE         = R_CODE.
        ELSE.
          STRERROR = C_ERROR4.
        ENDIF.
      ENDIF.
    ENDIF.
    Message was edited by: Mandar Shete

  • Http post from an application with file attachment

    Hi ! I didn't know where else to post this message...
    I'm trying to make a HTTP POST from an application and upload a file with it. I have no problems with the posting, just that I haven't got any ideas how to get the file uploaded as well. I've been reading loads of examples regarding the topic, and searching older posts the forum here, without any help.
    Here's the method i'm using:
                   // open connections
                  URL url = new URL ("TheURL");
                   URLConnection urlConn = url.openConnection();
                              // We do input & output, without caching
                   urlConn.setDoInput (true);
                   urlConn.setDoOutput (true);
                   urlConn.setUseCaches (false);
                              // multipart/form-data because we want to upload a file
                     urlConn.setRequestProperty ("Content-Type", "multipart/form-data");
                  // Open output stream
                     DataOutputStream printout = new DataOutputStream (urlConn.getOutputStream ());
                  // Set the actual content
                     String content = "upfile=" + System.getProperty("user.dir") + "\\file.ext&";
                       content += "other_key-value_pairs";
                  // write the data to stream, and flush it.
                     printout.writeBytes (URLEncoder.encode(content));
                   printout.flush ();
                   printout.close ();
                   // Get the response.
                     DataInputStream input = new DataInputStream (urlConn.getInputStream());
                   FileOutputStream fos=new FileOutputStream("postto.txt");
                   String str;
                     BufferedReader bufr = new BufferedReader(new InputStreamReader(input));
                  // Write response to outputfile
                     while (null != ((str = bufr.readLine()))) {
                         if (str.length() >0) {
                         fos.write(str.getBytes());
                         fos.write(new String("\n").getBytes());
                   input.close ();Now, the response here I get from the url i'm posting to is "Failure, no data-file". I've tried many diff methods of writing the file to the stream, but always get the same result.
    I need to file attached like it would be when using a HTML form's <input type="file">.
    Please help ! This is getting really urgent !

    String content = "upfile=" + System.getProperty("user.dir") + "\\file.ext&";
    content += "other_key-value_pairs";
    printout.writeBytes (URLEncoder.encode(content));
    printout.flush ();
    printout.close ();Actually, what this does is create a request like:
    GET /path/to/file/script.language?upfile=/home/user/file.ext&other=params HTTP/1.1
    Content-Type: multipart/form-data
    -- And other HTTP params --
    The file is not actually appended to the request.
    I really don't know how Java handles the file upload, but you could do it by hand, like so:
    public static void doFileUpload(String url, String filename, Hashtable params) throws IOException {
        // Construct the request
        String boundary = "----------------------mUlTiPaRtBoUnDaRy";
        String request_head = "POST " + url + " HTTP/1.0\r\n" +
                                         "Content-type: multipart/form-data; boundary=" + boundary + "\r\n";
        String request_body = boundary + "\r\n\r\nContent-disposition: form-data; name=\"upload\"" +
                                         "\r\n\r\n";
        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
        int b = -1;
        while((b = in.read()) != -1) {
             request_body += (char)b;
        in.close();
        Enumeration keys = params.keys();
        while(keys.hasMoreElements()) {
            String key = keys.nextElement();
            requst_body += "\r\n" + boundary + "\r\n\r\nContent-type: form-data; name=\"key\"\r\n" +
                                    (String)params.get(key);
        request_body += "\r\n" + boundary + "--\r\n";
        int length = request_head.length() + request_body.length() + "Content-length: \r\n";
        String req_length = "Content-length: " + (length + new String("" + length).length()) + "\r\n";
        Socket socket = new Socket(url,80);
        PrintStream stream = socket.getOutputStream();
        stream.print(request_head + req_length + req_body);
        // And now an option to read the response, I will omit that...   
    }Note: I have not tested this code, just wrote it up out of memory. If it does not work, it will propably need some small fixes.
    Tuomas Rinta

  • Remove charset=utf-8 from HTTP POST

    I'm trying to do a HTTP POST via ABAP.  The application that I'm posting to does not like the "charset=utf-8" that is in the request.  I've been told that I need to remove it.  Does anyone know how to do this?  I'm not setting this field.  SAP is adding this charset automatically.
    Here is the request:
    POST /hapld/tos/kdwhapltos HTTP/1.1
    content-type: multipart/mixed; boundary=BOUNDARY; charset=utf-8
    content-length: 2018
    host: www.pld-certify.ups.com
    user-agent: SAP Web Application Server (1.0;700)
    accept-encoding: gzip
    sap-trace: 3
    --BOUNDARY
    Content-type: application/x-www-form-urlencoded
    Content-length: 128
    AppVersion=1.0&AcceptUPSLicenseAgreement=Yes&ResponseType=application/x-ups-pld&VersionNumber=V4R1&UserId=xxxxxx&Password=xxxxxx
    --BOUNDARY
    Content-type: application/x-ups-binary
    Content-length: 1396
    020093  2010071800000006852703500   000000002*AA296007......etc
    BOUNDARY
    Here is my code:
    CALL METHOD cl_http_client=>create
        EXPORTING
          host          = POST_HOST
          service       = '443'
          scheme        = '2'
          ssl_id        = 'ANONYM'
       proxy_host    =  wf_proxy
       proxy_service =  wf_port
        IMPORTING
          client        = http_client.
      http_client->propertytype_logon_popup = http_client->co_disabled.
      wf_user = '' .
      wf_password = '' .
      data: lv_value type string.
      CALL METHOD http_client->request->set_header_field
        EXPORTING
          name  = '~request_method'
          value = 'POST'.
      CALL METHOD http_client->request->set_header_field
        EXPORTING
          name  = '~request_protocol'
          value = 'HTTP/1.1'.
    CALL METHOD http_client->request->set_header_field( name = '~server_protocol' value = 'HTTP/1.1' ).
      CALL METHOD http_client->request->set_header_field
        EXPORTING
          name  = 'HOST'
          value = POST_HOST.
      CALL METHOD http_client->request->set_header_field
        EXPORTING
          name  = '~request_uri'
          value = POST_URI.
    CALL METHOD http_client->request->set_content_type
        EXPORTING
          content_type = 'multipart/mixed; boundary=BOUNDARY'.
    CALL METHOD http_client->REQUEST->SET_HEADER_FIELD
        EXPORTING
          NAME = 'Accept-Charset'
          VALUE = 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'.
    CALL METHOD http_client->request->SET_FORMFIELD_ENCODING
        EXPORTING
          FORMFIELD_ENCODING = http_client->request->CO_ENCODING_URL.
      CALL METHOD http_client->request->set_cdata
        EXPORTING
          data   = wf_string
          offset = 0
          length = rlength.
      CALL METHOD http_client->send
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2.
      CALL METHOD http_client->receive
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2
          http_processing_failed     = 3.
      CLEAR wf_string1 .
      wf_string1 = http_client->response->get_cdata( ).

    Hi,
    I had a similar problem and could resolve it by using APPEND_DATA instead of APPEND_CDATA. Likewise, SET_DATA instead of SET_CDATA might solve the issue for you. The data has to be provided as binary data then.
    Regards,
    Stefan

  • Initiating an HTTPS post via Oracle Forms 6i

    Greetings all...
    Here is my problem. I would love some advise/next steps on solving it.
    We are currently using web-version of Forms 6i with the JInitiator 1.1.8.16. I have a new requirement for an existing form where it needs to initiate an HTTPS "post" (not "get") to a remote server and then receive a response of success or not and some other information that the form will then act upon. I believe this means I cannot simply use the "web.show_document" built-in because it uses the "get" method rather than the "post" method.
    Although I am a veteran Forms developer, I am new to all this java stuff. It has been recommended to me that I incorportate a JavaBean into the form to call on this remote service, but I have no idea what that means -- I've never opened JDeveloper. It was also mentioned that maybe there is already a JavaBean in existence that I can just use. I don't know what details of my situation would be useful to know to determine if one exists or not. Does this possibly existing JavaBean need to know already which URL I want to go to? Will it need to know the exact parameters I want to pass or could there be a JavaBean out there to simply "call any URL using the post method" regardless of the number of parameters to send it?
    I've looked through some of the forum for this question and since I'm clueless on java stuff, I didn't find anything that jumped out as an answer for me. Can someone (or many of you would be fine) clue me on the best approach? Thanx.
    Shane.

    Since the initial post above, I've discovered more to this situation that doesn't give me much hope of implementation.
    The "response" that I get back from the remove service is simply a "redirect" telling the initiating browser to go to a URL that I have to set up. When the response comes back, the remote service will tell the browser to go to this redirected URL with the "responses" as parameters in the URL resulting in the user's browser calling this "redirect" URL with a "get" method.
    Not sure what all that means to be honest, but am wanting to learn.
    Shane.

Maybe you are looking for