Post data to https URL not working!!

I currently have an issue with tunnelling through a 1.1 proxy with JSSE.
I used the SSLTunnelSocketFactory class (as defined in http://www.javaworld.com/javaworld/javatips/jw-javatip111-p2.html) and
tried to use it in my code.
Unfortunately, it doesn't work.
I'm trying to connect to a secure (https) website and post some xml to
it then read the response.
I write the xml to the output stream and then try to open the input
stream for reading back the response.
I get the following error:
Connection aborted by peer: socket write error
Does anyone have an example of code that will do a post of xml (or any
data) to a secure URL and read the results? Whether it's using apache's
httpclient, JSSE or something else?
Thanks for any help you can give.
Paul
Here's the code where it tries to connect:
String proxyHost = "212.120.142.235";
String proxyPort = "8088";
String response = "";
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
System.setProperty("https.proxyHost",proxyHost);
System.setProperty("https.proxyPort",proxyPort);
url = "https://website/remote.cgi";
URL remoteURL = new URL(url);
HttpsURLConnection connection = (HttpsURLConnection)remoteURL.openConnection();
if(connection instanceof com.sun.net.ssl.HttpsURLConnection){
((com.sun.net.ssl.HttpsURLConnection)connection).setSSLSocketFactory
(new SSLTunnelSocketFactory(proxyHost,proxyPort));
connection.setRequestProperty("USER_AGENT", "payandshop.com Connect V1.0 [Java 1.3.0]");
File f = new File(sFileName);
FileInputStream fis = new FileInputStream(f);
StringBuffer sb = new StringBuffer();
int i = 0;
while ((i = fis.read()) != -1)
sb.append((char)i);
try {
connection.setDoOutput(true);
PrintWriter printwriter = new PrintWriter(connection.getOutputStream());
printwriter.println(sb.toString());
printwriter.close();
} catch (IOException ioe) {
// can anything here be recoverable? - stop
System.out.println( "Error writing xml"+ioe.getMessage());
return;
String inputLine = null;
try {
InputStream is = connection.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader bufferedreader = new BufferedReader(isr);
while ((inputLine = bufferedreader.readLine()) != null) {
response += inputLine;
bufferedreader.close();

Hi, the problem is to do with the HTTP 1.1 proxy, not SSL itself.
Basically, if you connect through a proxy that is a 1.1 proxy, the
JSSE classes check for HTTP/1.0 in the status of the connection to
the proxy. This will fail due to the fact that HTTP/1.1 is returned
as part of the string (see javaworld url above for description of problem).
Anyway, my problem is trying to implement a workaround. My post
to the SSL site isn't working correctly.
Regards,
Paul

Similar Messages

  • Retrieving Posted Data in a URL

    I am trying to retrieve data that a third-party vendor is posting to a URL that I supply. I think that I need to use "utl_http.request_pieces(url)" to retrieve the data, but I get "SIGNATURE (parameter names) MISMATCH VARIABLES IN FORM NOT IN PROCEDURE: NON-DEFAULT VARIABLES IN PROCEDURE NOT IN FORM:.." when I printout the contents of the table. Is this error from my retrieval of the url contents or from the third-party vendor's post to the url? Am I doing something wrong? Is this the correct procedure to use to retrieve posted data from a URL that is not passed as parameters?
    Any help would be appreciated.
    Thank you.

    The reason I used deep linking was that was the only way that I could access the variables that were being sent from the first file. It took me most of the day finding a solution that would work! Is there a better way to capture the variables when I link to a file?
    Here's what works for me in the file I've connetced to (the critical line is:  userName=o.connectionPw;):
    import mx.managers.BrowserManager;
    import mx.managers.IBrowserManager;
    import mx.utils.URLUtil;
    private var bm:IBrowserManager;      
    public function init():void{
        bm = BrowserManager.getInstance();               
        bm.init("");
    // The following code will parse a URL that passes string parameters after the "#" sign; for example:
        var o:Object = URLUtil.stringToObject(bm.fragment);               
        userName=o.connectionPw;

  • [svn] 4377: Bug: BLZ-292 - Data Push sample does not work in BlazeDS Turnkey

    Revision: 4377<br />Author:   [email protected]<br />Date:     2008-12-22 16:16:25 -0800 (Mon, 22 Dec 2008)<br /><br />Log Message:<br />-----------<br />Bug: BLZ-292 - Data Push sample does not work in BlazeDS Turnkey<br />QA: Yes<br />Doc: No<br />Checkintests Pass: Yes<br /><br />Details:<br />* Regression due to some refactoring of user-agent handling that was failing to set up defaults if no explicit <properties> were defined for the <channel-definition>. This meant that for IE, no kick-start bytes were being pushed down the streaming connection at setup time...<br /><br />Ticket Links:<br />------------<br />    http://bugs.adobe.com/jira/browse/BLZ-292<br /><br />Modified Paths:<br />--------------<br />    blazeds/trunk/modules/core/src/flex/messaging/endpoints/BasePollingHTTPEndpoint.java<br />    blazeds/trunk/modules/core/src/flex/messaging/endpoints/BaseStreamingHTTPEndpoint.java<br />    blazeds/trunk/modules/core/src/flex/messaging/util/UserAgentManager.java

    Hi,
    Thanks for your feedback!
    This feature has been going through a lot of changes with the BlazeDS and Flash Builder builds.
    We request you to pick up the BETA2 build of Flash Builder and BlazeDS 4.0.0.10654, hopefully you should see things working fine.
    Kindly let us know if you still encounter problems.
    Thanks,
    Balaji
    http://balajisridhar.wordpress.com

  • Only posted values for Navigation does not work

    Hi,
    I have a problem where all master data is shown in the input help for a variable, even when the setting for the info object is to show only posted values.
    In a WEB template I have tree reports using tree different data providers. The setting in the web template is to show the same variable only once and that works. The setting of the info objects is to show only posted values. That does not work!
    When using the input help for a variable, all master data shows, not only the poster values in the data providers.
    When unchecking the setting Display Same Variable Only Once (MELT_VARBLES) the variables appears tree times each and the input help works as expected. It shows only posted values.
    Any experience of this?
    Best Regards
    Kent

    Hi Kent,
    If you build several queries on different infoproviders, then put them into one web template or workbook. Variables from different queries with the same technical name will get merged in variable screen (Set parameter MERGE_VARIABLES=True in web template property. Set "Display Duplicated Variables Only Once" in workbook settings for variables).
    This means, that it is not possible to decide which infoprovider the variable is based on. The provider is unknown to the system when doing F4 help so that D mode is not possible since D mode [Only Values in InfoProvider]  is also infoprovider dependent. So only M mode ['Values in Master Data Table'] is possible.
    In such merge variable situation, the authorizated values in F4 help is also retrieved without specific infoprovider.
    Regards,
    Nishant

  • Cannot move any files into trash to delete them. I get a Trash warning box saying "The Finder cannot complete the operation because some data in 'file name' could not be read or written.(Error code - 36)".Macbook has so much data it is almost not working

    Cannot move any files into trash to delete them. I get a Trash warning box saying "The Finder cannot complete the operation because some data in 'file name' could not be read or written.(Error code - 36)".Macbook has so much data it is almost not working.
    I have tried reseting to factory settings by removing battery and holding down the power switch for more than 5 sec but this does nothing.
    Any ideas would be greatly appreciated as I think with so much unwanted data on the desktop and other places the whole os will crash very soon.
    Thanks, Rick

    The hard drive may be dying anyway, or the directory damaged because it is so full.  You should never let the hard drive get over 85% full.
    A -36 error is a read/write error.
    All you did with the power is reset the SMC.  Does nothing to reset everything to factory settings. 
    Do you have your original 10.4 installer discs for the MacBook?
    Is your data backed up?

  • The date and time is not working after setting it to current date and goes back to may,26 2011

    the date and time is not working after setting it to current date and goes back to may,26 2011; 2 PM . I bought my ipod tocuh 4th gen on july 18th

    On the iPod, make sure your Calendar is set to Gregorian (Settings > General > International > Calendar).  Also make sure your date and time on your computer is correct as well as the Time Zones on both.

  • Hey, I wanna download Lion for free, so i need UP-TO-DATE , but it do not works , please help

    Hey, I wanna download Lion for free, so i need UP-TO-DATE , but it do not works , please help

    I think you misunderstood the guy. The up-to-date program isn't working for a lot of people. I'm eligible for the free upgrade but it fails to recognise my serial. From what I've read, this is affecting a lot of people who purchased their computers online. Apple seems to be fixing the issue though, so my advice would be to keep trying. Alternatively, click on the manual verificaton link so they can check your order for you and send the redemption code after they do.

  • Http connection not working on phone

    Hi i am trying to connect to a http server using the new nokia n95 phone with T-mobile web and walk(Unlimited 3g internet access)
    on the emulaor and on the phones wifi connection, it works. But when i try connecting to the server using gprs/3g it doesnt. The response code never equals to OK . here is my code below:
    I know it is not working because has soon as the program makes an attempted to connect, the root.notifyDestroy() closes the application as i expect it too
    server = (HttpConnection) Connector.open(url);
                server.setRequestMethod(HttpConnection.POST);
                int rc = server.getResponseCode();
                if (rc == HttpConnection.HTTP_OK)
                   is = server.openInputStream();
                else
                    root.notifyDestroyed();
                     Alert alert = new Alert ("Error");
                    alert.setString("Error, server is down");
                    alert.setTimeout (5000);
                    Display.getDisplay(root).setCurrent(alert);
                    throw new IOException("HTTP response code: " + rc);
                }

    I had all sorts of strange problems getting http connect to work from phones. Most of my problems were resolved by adding every single header I could find that tells the carrier's gateway to leave it alone. Try adding these headers to the connection from the phone, and the response from the server:
                        connection.setRequestProperty( "User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
                        connection.setRequestProperty( "Content-Type", "application/octet-stream");
                        connection.setRequestProperty( "Content-Length", ""+(allContentToSend.length));
                        connection.setRequestProperty( "Cache-Control","no-store");
                        connection.setRequestProperty( "Cache-Control", "no-cache");
              connection.setRequestProperty( "Pragma","no-cache");
              connection.setRequestProperty( "Cache-Control", "no-transform");
              connection.setRequestProperty( "Connection", "Keep-Alive");
              connection.setRequestProperty( "Proxy-Connection", "Keep-Alive");          
    The content-type will depend on what you are sending. octet-stream is for binary data. If you are just encoding parameters in your POST you may need something else like "application/x-www-form-urlencoded".
    The content-length is obviously dependant on what you are sending. The rest of the properties simply tell whoever is transporting the request to leave it alone.
    TEMP_MOVED sounds like a redirect or some odd thing. Maybe the carrier is caching the response, and you are actually getting something unnexpected.
    Hope this helps.

  • POST data as parameter but not in content?

    I need to send some data from a PDA to a server. This works ok via SOAP but is rather slow, so I want to use a more efficient approach: sending a custom XML directly to a servlet. For this I use the URLConnection and POST the XML directly.
    The data arrives in the servlet, but I am not able to extract it from the request. For some reason it is seen als a parameter but not in the content. I have captured the actual HTTP request being sent (stripped the remaining XML):
    POST /xxx/PdaOrder1Servlet HTTP/1.1
    User-Agent: Java1.3.0_02
    Host: localhost:8181
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alive
    Content-type: application/x-www-form-urlencoded
    Content-length: 541
    +<pdaorder pdaOrderNr="2" ...+
    As said, this arrives at the servlet, because when I print the parameter it has the data the was sent:
    DEBUG PdaOrder1Servlet.doPost(PdaOrder1Servlet.java:74) - -------------------------
    DEBUG PdaOrder1Servlet.doPost(PdaOrder1Servlet.java:75) - Processing request: POST http://localhost:8181/xxx/PdaOrder1Servlet / [<pdaorder  pdaOrderNr=>{"2" ...
    It maps the start of the XML "<pdaorder pdaOrderNr" as the key in the parameter and the remainder of the XML document as the value. But if I try to read the data using the reader:
                   BufferedReader in = new BufferedReader(request.getReader());
                   String decodedString;
                   while ((decodedString = in.readLine()) != null) System.out.println(decodedString);
                   in.close();I get nothing. How do I access the raw content being sent in the HTTP request? Why is the content of a POST interpreted as parameters?

    Sometimes typing a problem out helps: the content type of the request needed to be set to text/xml

  • Application URL not working properly

    We have a custom application hosted on weblogic8.1 cluster. And this is in production environment.
    What we observed was, I am using FireFox browser and works fine for me. And I noticed it did not work a few days ago only once. However, most of the other users use IE6.0 and seems not able to access this URL. So some tried using IE 7.0 and worked fine for some time. But, the problem persisted very often as few can and others cannot.
    Can anybody tell me what could be the problem or should I be modifying any files in weblogic server.
    This is working pretty fine in testing environement.

    Thank you very much for the hint, though I have not tried your suggestion. I tried a little more and found the following way might be simpler - using "java.url.*" and "java.io.*". Just a simple test:
    ============================
    URL url=new URL("ftp://usrname:password@hostname/localDirectory/filename.txt");
    InputStream is=url.openStream();
    BufferedReader in=new BufferedReader(new InputStreamReader(is));
    String line;
    while((line=in.readLine()) !=null) { System.out.println(line);
    ==========================================
    Of course, other data format would work in a similar way.
    Cheers,
    ljiang001

  • [LAVA Cross Post] CTRL+SHIFT+ Shortcuts sometimes not working in LabVIEW

    Cross-post from LAVA: http://lavag.org/topic/15619-ctrlshift-shortcuts-sometimes-not-working-in-labview/
    See the above post for more information - here's a synopsis:
    CTRL+SHIFT modifiers are not working while running LabVIEW in a Parallels 7 virtual machine. This problem affects both LV2011 and LV2012. I'm not certain that this is a LabVIEW bug - could be an issue with my virtual machine environment or it's configuration - except that CTRL+SHIFT modifiers work in other applications on the affected VMs. It's just LabVIEW that appears to ignore shortcuts with the CTRL+SHIFT modifiers.
    Any ideas? 
    a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;}

    X. wrote:
    Still well and alive in Parallels 9 and LabVIEW 2013 SP1. Of course I could upgrade to the latest versions to check whether things have gotten any better.
    Any news on that?
    @mellroth figured out the solution :-)
    a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;}

  • Formatted Search for Delivery Date field in SO not working

    Hi All
    Can anyone help me as to why my formatted search is not working?
    I am currently using SAP B1A SP01 Patch 19.
    I have created a user query as follows:
    SELECT $ [$10.0.DATE] + 5
    When I add this to the delivery field within the Sales Order and bring through the saved query which I set to auto refresh when the Posting Date field changes and to Display Saved Values it doesn't work.
    Any ideas?
    Thanks and best wishes
    Gail

    HI Gail,
    If I am not mistaken you want to add days to the posting date...if that is so then try this out:
    SELECT $[ORDR.DocDate.DATE]+5 From ORDR T0 For Browse
    Set The indicator to Auto Refresh when the fields change
    Nagesh

  • Some URL not working in XI 3.1

    Hi,
    URL below which is working in XI R2
    http://serverName/businessobjects/enterprise115/desktoplaunch/opendoc/documentXML.jsp?cmdP1=reportname01wid*&token=servername%40715252JKRqBkrcZktGziHM715251JzcHaz61ShIdevCP&cmd=askPromptView&cmdBlock=all&cmdP2=lsSP22%3D1%26lsSP21%3D1%26lsSP20%3D1%26lsSP9%3D0%26lsSP8%3D1%26lsSP7%3D1%26lsSP6%3D1%26lsSP5%3D1%26lsSP4%3D1%26lsSP3%3D1%26lsSP2%3D1%26lsMRMDB%3D582%26lsSP1%3D1%26lsSP19%3D1%26lsSP18%3D1%26lsSP17%3D1%26lsSP16%3D0%26lsSP15%3D0%26lsSP14%3D0%26lsSP13%3D1%26lsSP12%3D1%26lsSP11%3D0%26lsSP10%3D1%26lsMCustomer%3D18946%26sWindow%3DNew%26sOutputFormat%3DPDF
    We recently migrated to BOXI 3.1 but the New URL i have created for XI 3.1 which is not working and show blank page and display NULL on the page..
    http://servername/PerformanceManagement/scripts/documentXML.jsp?cmdP1=reportname01wid*&token=servername%40715252JKRqBkrcZktGziHM715251JzcHaz61ShIdevCP&cmd=askPromptView&cmdBlock=all&cmdP2=lsSP22%3D1%26lsSP21%3D1%26lsSP20%3D1%26lsSP9%3D0%26lsSP8%3D1%26lsSP7%3D1%26lsSP6%3D1%26lsSP5%3D1%26lsSP4%3D1%26lsSP3%3D1%26lsSP2%3D1%26lsMRMDB%3D582%26lsSP1%3D1%26lsSP19%3D1%26lsSP18%3D1%26lsSP17%3D1%26lsSP16%3D0%26lsSP15%3D0%26lsSP14%3D0%26lsSP13%3D1%26lsSP12%3D1%26lsSP11%3D0%26lsSP10%3D1%26lsMCustomer%3D18946%26sWindow%3DNew%26sOutputFormat%3DPDF
    Can anyone please help and give me some idea ?
    Thanks in advance.

    Hi RMTuck,
    I'm sorry to hear you are having these issues with your iPad after a recent update. If you continue to have issues sending or receiving iMessages, you may find the troubleshooting steps outlined in the following article helpful:
    If you can't send or receive messages on your iPhone, iPad, or iPod touch - Apple Support
    Regards,
    - Brenden

  • MobileMe Gallery URL Not working

    All of my MobileMe Gallery URL's in iPhoto do not work and contain '(null)' as in:
    http://gallery.me.com(null)/username/100016
    If I remove '(null)' it works fine. Anyone else have this problem?
    Thanks!

    First delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your User/Library/Preferences folder, republish the galleries and see if the URL gets changed.
    If not create a new gallery with the same photos from one of the existing galleries, name it the same as the old one, delete the existing gallery and publish the new one. See if that will generate correct URLs. The URL may change so you may have to re-announce it to your friends.
    OT

  • Link to URL not working in RH X5

    Good morning,
    A client asked me to include a hyperlink to an internal site of theirs.  After I gave them the WebHelp, they said the link doesn't work (I can't test it here as I work offsite without access to their intranet).  They said there is a space missing which would account for it not working.  The problem is I copied and pasted the URL into the project from the client's email.  Here is the URL copied from the client's email to me - you can see the 2 spaces between ACH and Forms.  :
    http://sharepoint.myfirstnet.com/TreasuryManagement/ACH%20%20Forms/Product%20Information/T raining/ACH_SEC%20Explained.doc
    When I right-click on the link in my topic and check the link properties and when I look at the code on the True Code tab, I can see the 2 spaces (not the code for the spaces, of course, but you can tell there is an extra space) so assumed all was well. Yet on the client's end there is only a single space.  And if I copy the link from the True Code tab in RH and past it here, for example, or into an email, it comes out like this:
    http://sharepoint.myfirstnet.com/TreasuryManagement/ACH Forms/Product Information/Training/ACH_SEC Explained.doc 
    The double space has been replaced with a single space.  I can't explain how or why that would be changed after I put in the hyperlink.  Is there something about HTML or RH in particular that doesn't allow double spaces so removes one?
    Thanks for any help.
    Diane

    Have you tried %20%20 in the code rather than spaces?
    Just a guess.
    See if that works in RoboHelp's viewer.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

Maybe you are looking for

  • Query performance problem

    I am having performance problems executing a query. System: Windows 2003 EE Oracle 9i version 9.2.0.6 DETAIL table with 120Million rows partitioned in 19 partitions by SD_DATEKEY field We are trying to retrieve the info from an account (SD_KEY) order

  • What is this icon in the top-right corner?

    I'm running iOS 5.0.1 on an iPhone 4S and when I run iHandySoft's Quick Scan Pro application, I get an icon that I don't recognize which replaces the battery icon in the status bar. This icon looks like a box with an arrow pointing down and to the ri

  • A problem about UWL substitution and GP

    Hi, Guys.      Can UWL substitution mechanism also include gp task? I have some gp tasks in my uwl. When I set someone as my substitution, all of my tasks can be seen by my substitution(besides gp tasks). Is it a system restriction or just I need to

  • Double.parseDouble(String) : Problem to parse large String

    Hello, I need to convert A String to a Double in my application without rounding of digits. I have used the Double.parseDouble(String) method. The maximum string length can be 17 including dot(.) So if my String is (of length 17) Eg. S= �9999999999.9

  • My battery drains really fast on my 2011 MacBook Pro after upgrading to Mavericks

    What can I do to fix the battery