POST through HTTPs

Hi, I try to perform http POST using
http://martin.nobilitas.com/java/cookies.html
it works.
However, when I try to perform POST using https, by using tips
// Dynamically register the JSSE provider.
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
// Set this property to use Sun's reference implementation of the HTTPS protocol.
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
it won't work anyone. I get error
Exception java.io.IOException: Server returned HTTP response code: 500 for URL: https://www.xyz.com/dologin.jsp
any suggestion?
thanks

* Main.java
* Created on April 15, 2007, 10:05 PM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package oskcookies;
import java.net.*;
import java.io.*;
* @author yccheok
public class Main {
    /** Creates a new instance of Main */
    public Main() {
/** Post a string to an URL and get the reply as a string. Returns an empty
string if things didn't work out. */
    static public String getURLPostString(URL url, String body) {
        StringBuffer sb = new StringBuffer();
     // find the newline character(s) on the current system
        String newline = null;
        try {
            newline = System.getProperty("line.separator");
        } catch (Exception e) {
            newline = "\n";
        try {
         // URL must use the http protocol!
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.setAllowUserInteraction(false); // you may not ask the user
            conn.setDoOutput(true); // we want to send things
            // the Content-type should be default, but we set it anyway
            conn.setRequestProperty( "Content-type", "application/x-www-form-urlencoded" );
            // the content-length should not be necessary, but we're cautious
            conn.setRequestProperty( "Content-length", Integer.toString(body.length()));
            // get the output stream to POST our form data
            OutputStream rawOutStream = conn.getOutputStream();
            PrintWriter pw = new PrintWriter(rawOutStream);
            pw.print(body); // here we "send" our body!
            pw.flush();
            pw.close();
            // get the input stream for reading the reply
            // IMPORTANT! Your body will not get transmitted if you get the
            // InputStream before completely writing out your output first!
            InputStream  rawInStream = conn.getInputStream();
            // get response
            BufferedReader rdr = new BufferedReader(new InputStreamReader(rawInStream));
            String line;
            while ((line = rdr.readLine()) != null) {
                sb.append(line);
                sb.append(newline);
            return sb.toString();
        } catch (Exception e) {
         System.out.println("Exception "+e.toString());
         e.printStackTrace();
        return ""; // an exception occurred
     * @param args the command line arguments
    public static void main(String[] args) {
        // TODO code application logic here
        try {
            // Dynamically register the JSSE provider.
            java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
            // Set this property to use Sun's reference implementation of the HTTPS protocol.
            System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
            URL url = new java.net.URL("https://www.abc.com/dologin.jsp");
            String txtUserName = "txtUserName="+URLEncoder.encode("username");
            String txtPassword = "txtPassword="+URLEncoder.encode("name");
            String _continue = "continue="+URLEncoder.encode("/quotes.jsp");
            String sessionError = "sessionError="+URLEncoder.encode("0");
            String body = txtUserName + "&" + txtPassword + "&" + _continue + "&" + sessionError;
            /* https://www.abc.com/dologin.jsp?txtUserName=username&txtPassword=password&continue=%2Fquotes.jsp&sessionError=0 */
            System.out.println(getURLPostString(url, body));
        catch(java.net.MalformedURLException exp) {
            exp.printStackTrace();
}please take note that, when i directly enter this URL in my web browser (https://www.abc.com/dologin.jsp?txtUserName=username&txtPassword=password&continue=%2Fquotes.jsp&sessionError=0), the page can be login successful.
However, if I execute the above code, I get the following error:
Exception java.io.IOException: Server returned HTTP response code: 500 for URL: https://www.abc.com/dologin.jsp

Similar Messages

  • Need Help in importing data through HTTP post by using OAF

    Hello Everyone,
    I have one requirement of importing data from Job Posting page of iRecruitment into other application or into other file like csv/xml/txt through HTTP post by using Oracle Application Framework.
    Please help me out in the same if anyone know about how to achieve this kind of requirement.
    Help is highly appreciated.
    Thanks,
    Arvind
    Edited by: user636850 on Sep 18, 2009 5:35 AM

    Hi Gaurav,
    Thanks for your reply. I know about export button but my requirement is to import data into other web based application through HTTP post.
    Thanks,
    Arvind

  • How to post multiple http requests using a single http connection in java

    I am using the httpurlconnection class and it allows only to post one request on a connection. I require to post multiple http requests by opening a single connection. Code examples please. Thanx in advance.

    Hi
    I found this article through Google. I hope it helps a little
    http://www.developer.com/tech/article.php/761521
    D

  • THROUGH HTTP CAN WE SEND FLAT FILE IN  PI7.3?

    Hi Experts,
    We have an requirement that Through HTTP can we send flat file in PI7.3.(For EX:source side HTTP and Target side is IDOC or PROXY)
    Can any one please suggest me how can I proceed for that?
    Please let me know if there is any Documents or Blogs are there related to above requirement...
    Thanks,
    Shaik

    Hi Shaik,
    You can try following approach might help.
    Tell the sender system to use post method for HTTP connection. In post method the particular application will hit to a URL and data will be passed. Source system should pass the data same as that of Text file. Use following link which will help you to convert the data sent as text into XML. Further you can use this XML to convert further into IDOC or proxy.
    Adapter User-Module for HTTP Adapter?

  • Can we pass values to custom headers through HTTP bindings in BPEL?

    hi,
    I have an urgent requirement where I have to pass values to custom headers of HTTP url through HTTP bindings in bPEL.
    Is it possible? Say I have a http url http://localhost:80/test.
    I need to post xml over the above HTTP url as well pass some values to the Custom Headers Variables.
    Can I achieve this functionality thorugh BPEL or not?

    Hi,
    My requirement is exactly the same as yours, can you please let me know what did you do to overcome the Oracle Forms Default change password screen.
    Regards,
    Praveen

  • FI posting through BAPI

    Hi experts
    Can i have the sample program for invoice posting through bapi ,

    hi,
    Please refer this link
    BAPI_ACC_INVOICE_RECEIPT_POST Error
    or
    search on this
    https://www.sdn.sap.com/irj/scn/advancedsearch?query=invoicepostingthrough+bapi&cat=sdn_all
    thanks

  • How to configure SSL in tomcat and transfer data through HTTPS.

    Hi all,
    I hav an urgent requirement for transfering data through HTTPS.But hav no idea how to achieve that,using SSL.
    For that i have to configure tomcat.What and all i hav to do
    download and which and all files i hav to alter for configuring the tomcat.
    seeking for ur help,
    thank you

    Multi-posted.
    http://forum.java.sun.com/thread.jspa?threadID=591116&messageID=3079266#3079266
    http://forum.java.sun.com/thread.jspa?threadID=591062&messageID=3078566#3078566
    http://forum.java.sun.com/thread.jspa?threadID=590987&messageID=3077736#3077736

  • How can I have my partner messages through HTTPS

    My partners would like to send messages through HTTPS and I see the following in one of the threads. Is this good even for HTTP(S) or only HTTP?
    "ou cannot create HTTP listening channel. There is one default HTTP listening channel which you should use -
    http://hostname:soa_server_port/b2b/httpReceiver or http://hostname:soa_server_port/b2b/transportServlet
    Your remote TP may post documents to above URL's.
    Thanks
    Venkat

    Venkat,
    It stands true for HTTPS as well. The partner should post documents on url (if SSL is enabled on SOA server)-
    https://hostname:soa_server_port/b2b/httpReceiver or https://hostname:soa_server_port/b2b/transportServlet
    If you are using any SSL off-loader at your gateway then the host and port will change accordingly.
    Regards,
    Anuj

  • Error while posting through tcode tbb1

    Hi All,
    While trying to post through TBB1, I'm getting the following error message:
    " S.E.201 Profit Center 001"
    While debugging I noticed that the FM 'TB_DEAL_FIX_POST' is returning an error in its error flag.
    Wating for your replies.
    Regards,
    Arnab

    hi,
    please check this link ,it will help you
    http://72.14.235.132/search?q=cache:V0BoGC09gZAJ:help.sap.com/bp_hightechv1600/HighTech_DE/Documentation/H83_BPP_EN_DE.docerrorSerialnumberislockedbyUserwhilepostingthrough+MIGO%2Bsap&hl=en&ct=clnk&cd=10&gl=in
    Thanks and regards
    Durga.K

  • Not able to download a big xml file through Http

    Hi
    I am trying to download a large file around 8 MB, but I am  not able to download this file through Http or WebClient. can anyone please let me know how can I download the large file in Windows Phone 8 through Http or WebClient.
    When I trying to download the file then System got hang for some time and after that connection break type of popup shown the  nothing happened.
    sandeep chauhan

    Hi Sandeep,
    I used
    this code snippet to download
    the sample file (9.9M) in windows phone 8, it seems work fine. Since you’ve not posted anything about your code, I suggest you test the above code to see if the problem is caused by your code snippet.
    Windows phone silverlight 8.1 provides an effective way to download large file.
    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.networking.backgroundtransfer.backgrounddownloader.aspx. Please consider if you can upgrade to silverlight 8.1
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

  • Send xml file from sap to third party url through https

    Hi,
    I have a requirement to send the xml file from ecc to a 3rd party url through HTTPS. How can we achieve this using ABAP.
    Client doesn't have XI enviroment. The client has provided the 3rd party url where the file needs to be uploaded.
    Please help ! <removed by moderator>
    Thanks in advance.
    Regards,
    Chitra.K
    Edited by: Thomas Zloch on Sep 12, 2011 12:58 PM

    Hi Chitra,
    I had similar requirement and here is what I did: -
    REPORT  Z_HTTP_POST_TEST_AMEY.
    DATA: L_URL               TYPE                   STRING          ,
          L_PARAMS_STRING     TYPE                   STRING          ,
          L_HTTP_CLIENT       TYPE REF TO            IF_HTTP_CLIENT  ,
          L_RESULT            TYPE                   STRING          ,
          L_STATUS_TEXT       TYPE                   STRING          ,
          L_HTTP_STATUS_CODE  TYPE                   I               ,
          L_HTTP_LENGTH       TYPE                   I               ,
          L_PARAMS_XSTRING    TYPE                   XSTRING         ,
          L_XSTRING           TYPE                   XSTRING         ,
          L_IS_XML_TABLE      TYPE STANDARD TABLE OF SMUM_XMLTB      ,
          L_IS_RETURN         TYPE STANDARD TABLE OF BAPIRET2        ,
          L_OUT_TAB           TYPE STANDARD TABLE OF TBL1024
    MOVE 'https://<hostname>/xxx/yyy/zzz' TO L_URL.
    MOVE '<XML as string>' TO L_PARAMS_STRING.
    *STEP-1 : CREATE HTTP CLIENT
    CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL
        EXPORTING
          URL                = L_URL
        IMPORTING
          CLIENT             = L_HTTP_CLIENT
        EXCEPTIONS
          ARGUMENT_NOT_FOUND = 1
          PLUGIN_NOT_ACTIVE  = 2
          INTERNAL_ERROR     = 3
          OTHERS             = 4 .
    "STEP-2 :  AUTHENTICATE HTTP CLIENT
    CALL METHOD L_HTTP_CLIENT->AUTHENTICATE
      EXPORTING
        USERNAME             = 'testUser'
        PASSWORD             = 'testPassword'.
    "STEP-3 :  SET HTTP HEADERS
    CALL METHOD L_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING NAME  = 'Accept'
                    VALUE = 'text/xml'.
    CALL METHOD L_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
        EXPORTING NAME  = '~request_method'
                   VALUE = 'POST' .
    CALL METHOD L_HTTP_CLIENT->REQUEST->SET_CONTENT_TYPE
        EXPORTING CONTENT_TYPE  = 'text/xml' .
    "SETTING REQUEST DATA FOR 'POST' METHOD
    IF L_PARAMS_STRING IS NOT INITIAL.
       CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
         EXPORTING
             TEXT   = L_PARAMS_STRING
         IMPORTING
               BUFFER = L_PARAMS_XSTRING
         EXCEPTIONS
            FAILED = 1
            OTHERS = 2.
    CALL METHOD L_HTTP_CLIENT->REQUEST->SET_DATA
        EXPORTING DATA  = L_PARAMS_XSTRING  .
    ENDIF.
    "STEP-4 :  SEND HTTP REQUEST
      CALL METHOD L_HTTP_CLIENT->SEND
        EXCEPTIONS
          HTTP_COMMUNICATION_FAILURE = 1
          HTTP_INVALID_STATE         = 2.
    "STEP-5 :  GET HTTP RESPONSE
        CALL METHOD L_HTTP_CLIENT->RECEIVE
          EXCEPTIONS
            HTTP_COMMUNICATION_FAILURE = 1
            HTTP_INVALID_STATE         = 2
            HTTP_PROCESSING_FAILED     = 3.
    "STEP-6 : Read HTTP RETURN CODE
    CALL METHOD L_HTTP_CLIENT->RESPONSE->GET_STATUS
        IMPORTING
          CODE = L_HTTP_STATUS_CODE
          REASON = L_STATUS_TEXT  .
    WRITE: / 'HTTP_STATUS_CODE = ',
              L_HTTP_STATUS_CODE,
             / 'STATUS_TEXT = ',
             L_STATUS_TEXT .
    "STEP-7 :  READ RESPONSE DATA
    CALL METHOD L_HTTP_CLIENT->RESPONSE->GET_CDATA
            RECEIVING DATA = L_RESULT .
    "STEP-8 : CLOSE CONNECTION
    CALL METHOD L_HTTP_CLIENT->CLOSE
      EXCEPTIONS
        HTTP_INVALID_STATE = 1
        OTHERS             = 2   .
    "STEP-9 : PRINT OUTPUT TO FILE
    CLEAR : L_XSTRING, L_OUT_TAB[].
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          TEXT   = L_RESULT
        IMPORTING
          BUFFER = L_XSTRING
        EXCEPTIONS
          FAILED = 1
          OTHERS = 2.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        BUFFER                = L_XSTRING
      TABLES
        BINARY_TAB            = L_OUT_TAB .
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       FILENAME                        = 'C:AMEYHTTP_POST_OUTPUT.xml'
      TABLES
        DATA_TAB                        = L_OUT_TAB .
    Also, following is the detailed link for use of HTTP_CLIENT class: -
    http://help.sap.com/saphelp_nw70ehp1/helpdata/EN/1f/93163f9959a808e10000000a114084/content.htm
    Also, in below link, you can ignore XI specific part and observe how its sending XML to external URL:-
    (I know it describes call to SAP XI server's URL, but it can be used to call any URL)
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/ae388f45-0901-0010-0f99-a76d785e3ccc
    In addition to all above, following configs to be present at ABAP application server: -
    1. The hostname used to URL should be present in SAP ABAP application server's 'hosts' file.
    2. Security certificate (if available) for URL to be called must be installed in SAP ABAP application server.
    Let me know if you achieve any progress with it...

  • Send email afer "FI document posted" through PRRW

    Experts:
    I want to send out an Email to applicent afer "FI document posted" through Tcode:PRRW , Is there have any user exits or BTE I could use?
    or some standard function provided by SAP?
    The reason for send mail is just want to let user know we got the receipts(sometimes needs several days by express) and ready to deal with
    Please advise!

    One simple way to achieve this is to build it into your workflow step, as the event CREATED gets triggered every time you save the trip in status 'to be settled'. But also everytime the trip is saved, the event CHANGED is triggered. So, you need a workflow step 'Wait for event CHANGED' what is ending the old workflow instance, whereas the actual CREATED creates a new instance.
    1. Events, which should be triggered in order to approve trip requests
       (entered by transaction TRIP) or trip Plans in general. These events
       are relevant for the manager responsible for the approving process.
       The events are:
       - 'PlanApproved'
       - 'PlanCreated'
       - 'PlanChanged'
       - 'PlanCancelled'
    2. Events, which should be triggered in order to approve trip payments.
       These events are relevant for the travel expense department, which
       has to release the payment process. The events are:
        - 'Changed'   (in the sense of Expense report changed)
        - 'Requested'
        - 'RequestApproved'
        - 'Created'
        - 'Approved'
        - 'Cancelled'
        - 'Deleted'
        - 'RequestCreated'
        - 'RequestWaits'
        - 'ExpenseWaits'
        - 'RequestSettled'
        - 'RequestTransferredFI'
        - 'ExpenseSettled'
        - 'ExpenseTransferredFI'
    (Documentation link)
    http://help.sap.com/saphelp_470/helpdata/en/d5/202038541ec006e10000009b38f8cf/frameset.htm
    So in this instance, whilst the standard template is delivered, you do need to configure an additional step in this case using "created" rather than "changed" to trigger the additional workflow needed  in addition to the steps delivered inside the
    workflow template.
    Hope it would help!
    Sally
    Edited by: Sally Redmond on Mar 6, 2012 4:51 PM

  • Getting Error while posting through KB11N : No true sender object entered

    HI Expert,
    We have stastical internal order defined and same we are using in Asset. Let me explain the scenarion.
    We created the Purchase requisition with the stastical Internal Order then we did Purchase Order and MIGO -Goods Receipt.
    Now we realised that wrong Internal Order  was used. Now we want to tranasfer cost from that Internal order to New Internal Order. we are trying to post through KB11N but while giving the all details i am getting error as per below;
    No true sender object entered
    Message no. BK175
    Diagnosis
    You have entered a statistical object as a sender. Statistical objects, however, are only intended for use with dual account assignments.
    Procedure
    1. If you require a dual account assignment, enter a true object as a sender also.
    We are using cost element with having cost element category 90.
    I don't no which is the true sender Object.
    Thanks in advance
    ealry help will be highly appreciated.

    Your postings had happened to a statistical internal order.  I hope the real postings might have happened to a cost centre.
    You cannot settle anything from a statistical internal order.  It is just for information purpose only.  If the above posting had captured a cost centre (real posting), you can distribute/assess the cost from the cost centre to a real internal order for your purpose.

  • How to add line items to Accounting Document posted through MIRO ?

    I need to perform Additional posting when Posting through MIRO transaction..i tried with INVOICE_UPDATE BADI but this was not useful...Please let me know if there is any way to add additional posting to Accounting Document created through MIRO.
    If any user exit , BADI ot BTE present?

    Hi,
    Check the BTE's:
    00001020     POST DOCUMENT:       Prior to final checks             SAMPLE_INTERFACE_00001020
    00001025     POST DOCUMENT:       Final checks completed       SAMPLE_INTERFACE_00001025
    00001030     POST DOCUMENT:       Posting of standard data     SAMPLE_INTERFACE_00001030
    00001050     POST DOCUMENT:       Accounting interface           SAMPLE_INTERFACE_00001050
    Thanks & Regards,
    Harish

  • Error when trying to access a form through https

    Hi,
    I'm facing this error when trying to access a form through https, i'm using OAS10g 10.1.2.3 over linux, it has webutil configured and is working perfectly with https
    I'm accessing the form through webcache.
    the error:
    Java Plug-in 1.6.0_37
    Usar versión JRE 1.6.0_37-b06 Java HotSpot(TM) Client VM
    Directorio local del usuario = C:\Users\Carlos
    c:   borrar ventana de consola
    f:   finalizar objetos en la cola de finalización
    g:   liberación de recursos
    h:   presentar este mensaje de ayuda
    l:   volcar lista del cargador de clases
    m:   imprimir sintaxis de memoria
    o:   activar registro
    q:   ocultar consola
    r:   recargar configuración de norma
    s:   volcar propiedades del sistema y de despliegue
    t:   volcar lista de subprocesos
    v:   volcar pila de subprocesos
    x:   borrar antememoria del cargador de clases
    0-5: establecer nivel de rastreo en <n>
    cargar: clase oracle.forms.webutil.common.RegisterWebUtil no encontrada.
    java.lang.ClassNotFoundException: oracle.forms.webutil.common.RegisterWebUtil
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Excepción: java.lang.ClassNotFoundException: oracle.forms.webutil.common.RegisterWebUtil
    cargar: clase oracle.forms.engine.Main no encontrada.
    java.lang.ClassNotFoundException: oracle.forms.engine.Main
         at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Excepción: java.lang.ClassNotFoundException: oracle.forms.engine.Mainwhat could be the reason it can not find the webutil libraries with https ?? i tried erasing the java's cache but still the same error :(
    Regards
    Carlos

    I got it, i only had to check the option 'Use SSL 2.0 compatible ClientHello format' from the java's control panel advanced tab.
    Metalink's note: 787739.1
    :)

Maybe you are looking for

  • Select Option's Context Element for the REPORT_ATTRIBUTE_ERROR_MESSAGE

    Hi, We're on 7.0 ehp1. I found a thread on same subject u201Cwdr:select_options and highlight Error Message with a Link to Inputfield u201C, Jul-23-2008, in which Thomas Jung gave an explanation of how to get the context element of the Select Options

  • New GL - Doc Splitting - Profit Center not hitting the Zero Balance GL

    Dear SAP New GL Gurus, I am trying to activate the doc splitting where the system uses a GL Account to ensure that Profit Center wise Trial Balances are tallied. I have done the following configuration till now, and I feel that these steps should ide

  • Message in adapter engine

    Hi all, We monitor messages in adapter engine through RWB. Can anyone tell me where these messages are stored?

  • Show lov records in ascending order

    we want lov to display the records in ascending order in forms. How can i do this ? please help!

  • CS6 Install failed

    CS6  install failed.  Program was the free upgrade from recently purchased CS5.  Downloaded without problems from Adobe.  About 3/4 of the way through the install I got an error message to the effect that the program was an unauthorized version.  Sup