HttpURLConnection on OS/390

If someone can give me the correct solution, I would be indebted.
I am running java 1.3 on OS/390 mainframe. I am trying to do a HttpURLConnection to another website. The problem is on the mainframe, the basis for OS/390 is ebcdic.
I can not get the connection to work, I get a 400 response. The same code runs fine on my pc, which runs the same jdk, but is ascii.
I have tried everything I can think of to change the encoding of the the HTTP request on the mainframe to ascii so the website can read it.
Can anyone help?

something like this should convert from ascii to ebcdic.
String sURL =
"http://www.yahoo.com";
     try {
     URL yahooURL = new URL(sURL);
     URLConnection urlconn = yahooURL.openConnection();
     urlconn.connect();
     InputStream is = urlconn.getInputStream();
     BufferedReader in = new BufferedReader(new InputStreamReader(is,"cp437"));
     if(in != null)
     {  String line = "";
          while((line=in.readLine()) != null)
          {    System.out.println(line); 

Similar Messages

  • Stuck Threads on weblogic 10.3.2 Holding lock HttpURLConnection

    We are having issue with STUCK THREADS on weblogic 10.3.2. Basically my application makes a lot of web service calls over HTTPS and once in a while I see few STUCK THREADS and most of the time they clear but sometimes I have to bounce my server to clean.
    I have a thread dump, according to this its holding lock at weblogic.net.http.HttpURLConnection.getInputStream
    Any help to resolve this problem is highly appreciated.
    ThreadDump:
    <May 24, 2011 9:59:08 AM EDT> <Error> <WebLogicServer> <BEA-000337> <[STUCK] ExecuteThread: '11' for queue: 'weblogic.kernel.Default (self-tuning)' has been busy for "604" seconds working on the request "weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl@b607d75", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
    Thread-75 "[STUCK] ExecuteThread: '11' for queue: 'weblogic.kernel.Default (self-tuning)'" <alive, in native, suspended, priority=1, DAEMON> {
    jrockit.net.SocketNativeIO.readBytesPinned(SocketNativeIO.java:???)
    jrockit.net.SocketNativeIO.socketRead(SocketNativeIO.java:31)
    java.net.SocketInputStream.socketRead0(SocketInputStream.java:???)
    java.net.SocketInputStream.read(SocketInputStream.java:107)
    weblogic.utils.io.ChunkedInputStream.read(ChunkedInputStream.java:149)
    java.io.InputStream.read(InputStream.java:85)
    com.certicom.tls.record.ReadHandler.readFragment(Unknown Source)
    com.certicom.tls.record.ReadHandler.readRecord(Unknown Source)
    com.certicom.tls.record.ReadHandler.read(Unknown Source)
    ^-- Holding lock: com.certicom.tls.record.ReadHandler@bec563c[thin lock]
    com.certicom.io.InputSSLIOStreamWrapper.read(Unknown Source)
    java.io.BufferedInputStream.fill(BufferedInputStream.java:189)
    java.io.BufferedInputStream.read(BufferedInputStream.java:236)
    ^-- Holding lock: java.io.BufferedInputStream@bec5d9f[thin lock]
    weblogic.net.http.MessageHeader.isHTTP(MessageHeader.java:214)
    weblogic.net.http.MessageHeader.parseHeader(MessageHeader.java:141)
    weblogic.net.http.HttpClient.parseHTTP(HttpClient.java:452)
    ^-- Holding lock: weblogic.net.http.HttpsClient@bec5202[thin lock]
    weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:328)
    weblogic.net.http.SOAPHttpsURLConnection.getInputStream(SOAPHttpsURLConnection.java:37)
    ^-- Holding lock: weblogic.net.http.SOAPHttpsURLConnection@bd3b209[thin lock]
    weblogic.net.http.HttpURLConnection.getResponseCode(HttpURLConnection.java:939)
    com.sun.xml.ws.transport.http.client.HttpClientTransport.readResponseCodeAndMessage(HttpClientTransport.java:213)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:116)
    com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:101)
    com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:580)
    com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:553)
    com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:535)
    com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:433)
    ^-- Holding lock: com.sun.xml.ws.api.pipe.Fiber@bd3afa8[thin lock]
    com.sun.xml.ws.client.Stub.process(Stub.java:238)
    com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
    com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
    com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:116)
    $Proxy107.jobSubmit(Unknown Source)
    com.somejob.invokeService(JobOperation.java:53)
    com.somejobws.operations.ticket.execute(ticket.java:30)
    com.somejobutil.Somehelper.process(Somehelper.java:174)
    com.somejobutil.Somehelper.processJob(Somehelper.java:147)
    com.somejobutil.Somehelper.processMDB(Somehelper.java:91)
    com.somejobejb.ProcessMDB.onMessage(ProcessMDB.java:28)
    sun.reflect.GeneratedMethodAccessor109.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:575)
    com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:102)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:86)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:102)
    com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
    com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:151)
    $Proxy67.onMessage(Unknown Source)
    weblogic.ejb.container.internal.MDListener.execute(MDListener.java:403)
    weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:352)
    weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:264)
    weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4564)
    weblogic.jms.client.JMSSession.execute(JMSSession.java:4060)
    weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3746)
    weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5096)
    weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:198)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:165)
    }

    Yes, we have the same problem, stuck thread on weblogic.net.http.HttpsURLConnection.getResponseCode() (actually implemented by weblogic.net.http.SOAPHttpsURLConnection which also appears to be deprecated ???)
    When we use the class javax.net.ssl.HttpsURLConnection the getResponseCode() method works perfectly well, so it looks like the weblogic implementation is to blame.
    This is becoming rather urgent now because we're looking to migrate from OC4J to Weblogic and this issue has therefore become a blocker.

  • Problem with HttpURLConnection and HttpSession.

    Hi,
    Problem with HttpURLConnection and HttpSession.
    I created a HttpSession object in my main class and then called a URL via HttpURLConnection.
    I tried to access the same session object from the servlet called by the URL . but the main session
    is not returned a new seperate session is created.let me know how can we continue the same session in
    the called URL also which is created in main class.
    Thanks
    Prasad

    You are not supported to create a HttpSession by java client. Only J2EE web container can create it.

  • HttpURLConnection.connect() takes long time (3 minutes)

    I'm stumped on an unusual problem. I'm running java 1.3 and Apache JServ (don't ask, I inherited this set up), using JSSE. One of the things we do with our app involves some xml communication over SSL.
    Starting last week, the time for the SSL communication jumped from about 15 seconds to around 3 minutes.
    Here is the bit of code that does the actual communication. An example function call would be:
    contactService("ShipConfirm", "ups.app/xml");and the function definition:
    public void contactService(String service, String prefix)  throws Exception {
      HttpURLConnection connection;
      URL url;
      // the next 2 variables are stored elsewhere in the object
      // these values are just examples of one invocation
      String protocol = "https";
      String hostname = "wwwcie.ups.com";
      String urlStr = protocol + "://" + hostname + "/" + prefix + "/" + service;
      // so for this test urlString = "https://wwwcie.ups.com/ups.app/xml/ShipConfirm";
      try  {
        if (protocol.equalsIgnoreCase("https")) {
          java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
          System.getProperties().put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
        url = new URL(urlString);
        // Trace.log is a convenience class that will print to a log file and include a timestamp
        Trace.log("open connection to " + urlString);
        connection = (HttpURLConnection) url.openConnection();
        // openConnection takes about 20 seconds now, before 1 or 2 seconds
        Trace.log("opened connection to " + urlString);
        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setUseCaches(false);
        // XmlIn is an already generated xml file stored in a StringBuffer, declared elsewhere
        String queryString = XmlIn.toString();
        Trace.log("xml connection to " + urlString);
        connection.connect();
        // connect takes about 3 minutes 10 seconds now, before 15 seconds
        Trace.log("xml connection complete " + urlString);
        OutputStream out = connection.getOutputStream();
        out.write(queryString.getBytes());
        out.close();
        String data = "";
        try {
          // on the server this is actually a separate function
          StringBuffer buffer = new StringBuffer();
          BufferedReader reader = null;
          try {
            reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line = null;
            int letter = 0;
            while ((letter = reader.read()) != -1)
              buffer.append((char) letter);
          catch (Exception e) {
            // Trace.major is like Trace.log, but is a higher severity
            Trace.major("Cannot read from URL" + e.toString());
            throw e;
          finally {
            try {
              reader.close();
            catch (IOException io) {
              Trace.major("Error closing URLReader!");
              throw io;
          data = buffer.toString(); // actually a return statement on server
        catch (Exception e) {
          Trace.major("Error in reading URL Connection" + e.getMessage());
          throw e;
        XmlOut = new StringBuffer(data);  // XmlOut is a StringBuffer declared elsewhere
      catch (Exception e1) {
        Trace.major("Error sending data to server" + e1.toString());
    } Besides a couple of new Trace.log statements to pin down the what, exactly, is taking so long, I haven't touched this code in the year+ since I've inherited it. There haven't been any changes in the network setup for the last 3 weeks, either (last change was new reverse lookup zone for our internal network).
    Any idea why the HttpURLConnection.connect() would take so long? Or any idea how I can find out what is going on for those 3 minutes? In my search so far, I found -Djava.net.debug=ssl,handshake,data and added it to my startup parameters, but in my frustration, I must have overlooked what I need do to make it show up in my logs.
    I set up a tcpdump on the server to listen on the IP that I'm trying to connect to and the "xml connection to" log statement prints, then about 3 minutes and 10 seconds goes by, then tcpdump reports that we actually send the packets to the other server, then we get a response and print the "xml connection complete" log message. URL and HttpURLConnection are not subclassed at all.
    To make things even more interesting, I broke out this code, and wrote a small test program. The test program has some minor changes (pulling the xml data from an already existing file, mainly), and this version runs lickety-split (about 5 seconds).
    Any help or pointers would be greatly appreciated. Let me know if I can provide any more information.
    Thanks,
    Andy

    Figured it out..
    The other side removed a proxy server that we used to try to connect through. The server was taking 3 minutes and 10 seconds to time out when it trying to contact the proxy server.
    To be honest, I don't know if we ever successfully connected through the proxy server. I'm inclined to believe we tried to contact it, but were rejected, but no one ever removed the proxy code.
    Andy

  • How to open 2 HttpURLConnections in the same session

    Dear,
    I'm writing a client application that use HTTP GET request to get infomation from a web-server. Before getting any infomation, the web-client need to login.
    When using the browser, I can't get infomation through these steps:
    First, go to the URL login.jsp?username=myUser. This username will be keep in the http session variables. Then, I can get info through the page getinfo.jsp.
    Now, I want to do these steps in my java client app. My code is as follow:
          URL url = new URL("http://myhost:8080/test/login.jsp?username=myUser");
          HttpURLConnection urlCon = (HttpURLConnection)url.openConnection();
          url = new URL("http://myhost:8080/test/getinfo.jsp");
          urlCon = (HttpURLConnection)url.openConnection();I known that the session variables were lost between two openConnection() method.
    So, how can I keep my session variables? (I have no permission to change code of the server).
    Please help me!
    Thanks!

    Sorry - I missed the point about not having permissions on the server.
    In that case, I would try working out how the site normally tracks the session. If it inserts a sessionId in to every link, you need to include that in your request to getInfo.jsp.
    If it uses cookies, look at the headers for a field named "Set-Cookie":
    for (int i=0; ; i++) {
       String headerFieldKey = conn.getHeaderFieldKey(i);
       if ("Set-Cookie".equalsIgnoreCase(headerFieldKey)) {
    }Then use setRequestProperty() to send the same cookie (proably the username or a session id) to getInfo.jsp. I think that will work.
    Make sure you ask the site owner if you are using this for harvesting content!
    --Jon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can you Ignore Error Response Code in HttpUrlConnection?

    I have a problem with a HttpUrlConnection object throwing an IOException when it gets an HTTP Error Response code. Especially when there is an actual response from the server sent back that has more details in it that are actually helpful.
    I would like to just tell the HttpUrlConnection ot ignore HTTP error responses and just pass along the page or data that was returned instead. I need to handle this myself.
    The reason if it matters, is I am sending SOAP Envelopes, and if the Web Service doesn't like it, it will send an HTTP 500 Response Code, but it also sends a response SOAP Envelope that tells me exactly what is wrong.
    Right now to get this response I have to use a Sniffer, or worse since it is HTTPS (ssl) i have to use the jvm's SSL debug mode, and pull the response out of the hex code.
    I couldn't find anything about this, so I am afraid I am SOL, just hoping that there might be an obscure "feature" or "property" that can deal with this, that I can't find.
    ** 10 Duke Dollars to first person to provide a solution that works **

    Just call the getErrorStream() method to read the error response. Eg.
    HttpURLConnection conn = null;
    try {
      conn = (HttpURLConnection)
        new URL("http://www.google.com/givemea404").openConnection();
    } catch (Exception e) {
      InputStream in = conn.getErrorStream();
      int i = in.read();
      while (i != -1) {
        System.out.print((char) i);
        i = in.read();
    }

  • Can I log in a site only with HttpUrlConnection?

    I'm trying to write a small program which help me to log into my Megaupload account and manage my own stuffs there. But I met a obstacle right from the start, login site.
    After reading some of Sun's ["working with URLs" lesson|http://java.sun.com/docs/books/tutorial/networking/urls/index.html] and searching around, I've tried coding a small method to do this step. As the following:
    try{
           URL mega = new URL("http://megaupload.com/?c=login");
           String data = URLEncoder.encode("login=1&
                                                            redir=1&
                                                            username=my_username&
                                                             password=my_password","UTF-8");
            HttpURLConnection connection = (HttpURLConnection)mega.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Host", "megaupload.com");
         connection.setRequestProperty("Cookie", cookie);
         connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)");
         connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
            connection.setRequestProperty("Accept-Language", "en-us, en;q=0.5");
         connection.setRequestProperty("Accept-Encoding", "gzip,deflate");
         connection.setRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
         connection.setRequestProperty("Keep-Alive", "115");
            connection.setRequestProperty("Connection", "keep-alive");
         connection.setRequestProperty("Referer", "http://megaupload.com/?c=login");
         connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
         connection.setReadTimeout(10000);
         connection.setRequestProperty("Content-Length", Integer.toString(data.getBytes().length));
         connection.setDoInput(true);
         connection.setDoOutput(true);
            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
         wr.writeBytes(data);
         wr.flush();
         wr.close();
           //Codes to reading the response from MU
    }catch(Exception e){
    }The headers i receipt was exactly the same as using Firefox, but the html body was always of the login site instead of redirecting to the home page with logged in status. After some failed attempts to solve it myself, I came up searching help from this forum, and realized that there's lots of problem similar to mine. However, not any of them is absolutely solved without using external libraries (HttpsClient). I wonder if I can do it only with existing internal libraries. If yes, what I need to do?
    Thanks in advanced for help, and sorry for my bad English.

    I modified it:
    String data  = URLEncoder.encode("login", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8");
    data  += "&" + URLEncoder.encode("redir", "UTF-8") + "=" + URLEncoder.encode("1", "UTF-8");
    data  += "&" + URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode("chihuongbk", "UTF-8");
    data  += "&" + URLEncoder.encode("password", "UTF-8") + "=" + URLEncoder.encode("19881026h", "UTF-8");
    ..........Got the same result. I think that's not the problem. I feel there is something missing. Can you tell me whether I can log in the site this way with some more modifications !??

  • How to set HttpURLConnection timeout while reading a stream?

    I want it got time out if the connection if lose while i read a stream from URL
    try {
         int timeout = 700;
         HttpURLConnection connection = (HttpURLConnection) downloadURl.openConnection();
         connection.setConnectTimeout(timeout);
         connection.setRequestProperty("Range","bytes=" + downloaded + "-");
         connection.connect();
         if (connection.getResponseCode() / 100 != 2) {
              error();
         int contentLength = connection.getContentLength();
         if (contentLength < 1) {
              error();
         if (status == DOWNLOADING){
              if (size == -1) {
                   size = contentLength;
              file = new RandomAccessFile(saveTmpName+".tmp", "rw");
              file.seek(downloaded);
         byte buffer[];
         stream = connection.getInputStream();
    connection.setReadTimeout(timeout);
         while (status == DOWNLOADING) { 
              if (size - downloaded > MAX_BUFFER_SIZE) {
                   buffer = new byte[MAX_BUFFER_SIZE];
              } else {
                   buffer = new byte[(int)(size - downloaded)];
              int read = stream.read(buffer); // how to set timeout while it is reading stream
              if (read <= 0)
                   break;
              file.write(buffer, 0, read);
              downloaded += read;
         if (status == DOWNLOADING) {
              status = COMPLETE;
    } catch (SocketTimeoutException  e) {
         error();
    } catch (IllegalArgumentException e) {
         error();
    } catch (Exception e) {
         error();
    } finally {
         if (file != null) {
              try {
                   file.close();
              } catch (Exception e) {}
         if (stream != null) {
              try {
                   stream.close();
              } catch (Exception e) {}
    }I try to set "setReadTimeout()" but is still not through timeout Exception

    ejp wrote:
    Because, there's no FTP client command that allows to do such thing.Socket.setSoTimeout().I agree with you on this one but the OP is talking about the FTPClient API from Apache.
    To the OP,
    BTW, I have reread the Javadoc about the [*API*|http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html] : indeed, there's no setTimeout method, but there is a setDataTimeout method : +Sets the timeout in milliseconds to use when reading from the data connection+ .

  • 500 Error code while consuming web service using HTTPURLConnection

    Hi,
    I am getting an HTTP response code 500 and an IOException when I run a web service client to invoke a BMC Remedy web service (document based). I am using XML over HTTP to hit the web service as follows:
    // For Remedy
    soapAddress = "http://www.test-sislhelpdesk.siemens.co.in/arsys/services/ARService?server=bomw041a&webService=WebService_Test";
    soapEnvelope = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SOAP-ENV:Header><AuthenticationInfo><userName>webservice</userName><password>*******</password></AuthenticationInfo></SOAP-ENV:Header><SOAP-ENV:Body><Q1:OpGetList xmlns:Q1=\"urn:WebService_Test\"><Q1:Qualification></Q1:Qualification></Q1:OpGetList></SOAP-ENV:Body></SOAP-ENV:Envelope>";
    soapAction = "urn:WebService_Test/OpGetList";
         URL url = new URL(soapAddress);
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         System.out.println ("Connection got");
         connection.setDoOutput(true);
         connection.setRequestProperty("Content-Type","text/xml");
         connection.setRequestProperty ("soapAction", "\"" + soapAction + "\"");
         OutputStreamWriter outputStream = new OutputStreamWriter(connection.getOutputStream());
         System.out.println ("outputstream got");
         outputStream.write(soapEnvelope);
         outputStream.flush();
         BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
         String line = null;
         while ((line = reader.readLine()) != null)
              writer.write(line);
              writer.write("\n");
         System.out.println (writer);
         catch(Exception e){
              e.printStackTrace();
    I have created a .NET client proxy which seems to work well.
    I am not able to figure out as to why this code is not working. May be something wrong with the SOAP message request I am sending? But I have created this SOAP request message from the log generated for a successful hit. Any help in this regard will be highly appreciated.
    The web service is on the internet and hance is accessible to all :)
    Regards
    Vaibhav

    Tried "POST" request method, did not work.
    Actually when i hit other web services (created by me) , the code works.
    But when I hit a third party web service, it fails returning 500 error code.
    How can I extract the SOAP message returned, if any and see thinggs for myself.
    I guess there is something wrong with the request SOAP message which I am sending.

  • Exception: java.lang.ClassCastException: HTTPClient.HttpURLConnection

    Hi All,
    I am getting below exception when I am trying to establish HTTPS connection using
    Exception: java.lang.ClassCastException: HTTPClient.HttpURLConnection
    sometime my code works and some time it gives me this exception
    below is the exception which i traced in a log file
    2008/09/11 01:07:57->1_1210001776_0:1_1210001776_0URL CONNECTION CALLED https://netfundstest.com/fsu/router
    2008/09/11 01:07:57->1_1210001776_0:1_1210001776_0URL CONNECTION Created HTTPClient.HttpURLConnection[https://netfundstest.com/fsu/router]
    2008/09/11 01:07:57->1_1210001776_0:entered into else Block
    2008/09/11 01:07:57->1_1210001776_0:1_1210001776_0Error URLC Not a instance of HTTPS Connection: HTTPClient.HttpURLConnection[https://netfundstest.com/fsu/router]
    2008/09/11 01:07:57->1_1210001776_0:Exception: java.lang.ClassCastException: HTTPClient.HttpURLConnection
    In the success case when my HTTPS connection gets established I am getting following in the log file.
    2008/08/24 11:51:28->1_1210001776_0:1_1210001776_0URL CONNECTION CALLED https://netfunds.com/fsu/router
    2008/08/24 11:51:28->1_1210001776_0:1_1210001776_0URL CONNECTION Created com.sun.net.ssl.internal.www.protocol.https.DelegateHttpsURLConnection:https://netfunds.com/fsu/router
    Here is the code which I am using
    I am importing following packages in my code
    import java.security.*;
    import java.security.cert.*;
    //import javax.net.ssl.*;
    import javax.net.ssl.SSLSocket;
    import javax.net.ssl.SSLSocketFactory;
    import javax.net.ssl.HandshakeCompletedListener;
    import javax.net.ssl.HandshakeCompletedEvent;
    import javax.net.ssl.SSLSession;
    import java.net.*;
    import java.util.*;
    import java.io.*;
    //import javax.security.cert.*;
    import com.sun.net.ssl.*;
    //import org.apache.xalan.*;
    //import org.apache.xerces.*;
    import org.apache.xerces.dom.*;
    import org.apache.xml.serialize.*;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import oracle.xml.classgen.*;
    try
    System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
    System.setProperty("https.proxyHost",geProxy);
    System.setProperty("https.proxyPort",geProxyPort);
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    int n=0;
    while(n<3)
    debugMsg(instCount+"URL CONNECTION CALLED " + fsuFrontEndURL);
    url = new URL(fsuFrontEndURL);
    /* Changed to include Tunnel code */
    urlc = url.openConnection();
    debugMsg(instCount+"URL CONNECTION Created " + urlc);
    if (urlc instanceof com.sun.net.ssl.HttpsURLConnection)
    debugMsg("entered into If Block");
    debugMsg("Value of n:" + n);
    ((com.sun.net.ssl.HttpsURLConnection) urlc).setSSLSocketFactory(new SSLTunnelSocketFactory(geProxy, geProxyPort));
    ((com.sun.net.ssl.HttpsURLConnection) urlc).setRequestMethod("POST");
    debugMsg("after If Block");
    break;
    else {
    try{
    debugMsg("entered into else Block");
    ((javax.net.ssl.HttpsURLConnection) urlc).setSSLSocketFactory(new SSLTunnelSocketFactory(geProxy, geProxyPort));
    ((javax.net.ssl.HttpsURLConnection) urlc).setRequestMethod("POST");
    debugMsg("after else Block");
    break;
    catch(Exception e) {
    debugMsg(instCount+"Error URLC Not a instance of HTTPS Connection: " + urlc);
    debugMsg("Exception: " + e);
    I am using JDK 1.5 and Apache/1.3.19
    Can anyone help me out ....?

    for URL'S Starting with HTTPS only.....Sometimes it works and sometimes it gives me the classcast exception
    As soon as I bounces my Apache application server...then it starts working...I dont know why its happening like that..
    Is there any issue with the Ports I am trying to connect or some Apache configuration files settings are getting changed ?

  • NullPointerException while connecting through HTTPUrlConnection with JavaUpdate 51

      Hi,
    My java version is
    java version "1.7.0_51"
    Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
    I have a server/Device having untrusted certificate. When i connect to this device using HttpURLConnection its throwing null pointer exception as below.
    The update51 has introduced many security things, but i belive it should pop-up a dialogue for the untrusted certificate not the NPException. Seems like a clear bug in Oracle java update51. I have created a bug in bugs.sun.com but i dont see my bug id is visible in their bug database.
    Steps to reproduce.
    ----------------------------------------------- Start----------------------------------------
    package com.xyz;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;
    public class Test {
        public static void main(String[] args) throws IOException {
            TrustManager.installDeployTrustManager();  // We are using "com.sun.deploy.security.X509Extended7DeployTrustManager".
            URL url = new URL("https://hostname/admin/version.xml");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
           BufferedReader br =
                 new BufferedReader(
                         new InputStreamReader(conn.getInputStream()));
         String input;
         while ((input = br.readLine()) != null){
            System.out.println(input);
    ---------------------------End of code snippet----------------------
    replace the URL with your server Ip address which is having untrusted certificate. or change your PC time to feb 2015 and give the google ip address in the URL.
    I see the following exception.
    --------------------------------Start of the exception--------------------
    java.lang.NullPointerException
        at com.sun.deploy.security.DeployManifestChecker.printWarningsIfRequired(Unknown Source)
        at com.sun.deploy.security.TrustDeciderDialog.doShowDialog(Unknown Source)
        at com.sun.deploy.security.TrustDeciderDialog.showDialog(Unknown Source)
        at com.sun.deploy.security.TrustDeciderDialog.showDialog(Unknown Source)
        at com.sun.deploy.security.X509Extended7DeployTrustManager.checkServerTrusted(Unknown Source)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at com.cisco.launcher.Test.main(Test.java:17)
    Exception in thread "main" javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Java couldn't trust Server
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
        at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
        at com.xyz.Test.main(Test.java:17)
    Caused by: java.security.cert.CertificateException: Java couldn't trust Server
        at com.sun.deploy.security.X509Extended7DeployTrustManager.checkServerTrusted(Unknown Source)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1323)
        ... 12 more
    -------------------------------------------------End-------------------------------------------
    Further note:
    i see the doShowDialog() function in com.sun.deploy.security.TrustDeciderDialog has a new call to printWarningsIfRequired in DeployManifestChecker class.
    static void printWarningsIfRequired(URL paramURL, AppInfo paramAppInfo)
        String str1 = (String)ToolkitStore.get().getAppContext().get("deploy-" + paramURL);
        Resource localResource = ResourceProvider.get().getCachedResource(paramURL, str1);
    /// But here the str1 itself null or the Map doesnt have any key called "deploy-" + paramURL. So i guess its failing there.
    In my opinion the call to this function should be available only incase of a webstart and not for the standalone applications.

    I get the same error and try to turn off hostname verification by using the option :
    -Dweblogic.security.SSL.ignoreHostnameVerification=true
    but it does not seem to take this option. But wl 8.1 sp2 works. It starts fail to work since 8.1 sp3. I am looking for a solution as well. Any help would be appreciated.

  • Why can't I read the content of my HttpUrlConnection?

    Hey all. I am having problems with the code below. I have run it through a tcp trace, so i know the responce I am getting from my
    webservice i call.
    The problem is, the Content Length http header in the webservice request is set to 0. There is a body in the request of the message.
    When I try to do the input sream read, it always shows there is nothing in the unput stream! How can that be when there is a full responce in the body? Does the HttpUrlConnection just tell you there is nothing based on the Content Length header?
    any help woule be very appreciated. Thanks!
    import java.net.*;
    import java.io.*;
    public class Test {
    public static void main(String[] args) {
    try {
    String urlString = "http://SomeInternalUrlICantShowYou";
    URL url = new URL(urlString);
    HttpURLConnection huc = (HttpURLConnection)url.openConnection();
    huc.setUseCaches(false);
    huc.setRequestMethod("GET");
    huc.connect();
    System.out.println(huc.getContentLength());
    BufferedReader in = new BufferedReader( new InputStreamReader(huc.getInputStream()));
    int i = in.read();
    while(i!=-1) {
    System.out.println((char)i);
    i = in.read();
    in.close();
    huc.disconnect();
    catch (Exception ex) {
    ex.printStackTrace();
    }

    As I understand from your post that the remote server you are trying to access has the set the content-length in the header field as 0!!?? Seriously that I dont know how they did it. Might be when the reply is being send then they modify the response header.. That will be interesting to checkout how!! Anyways assuming that the Content-Length is 0 then below might be the possible explanation.
    There is nothing wrong in your code. As per RFC 2068 (HTTP/1.1protocol)
    section 14.14 Content-Length you will find that the applications SHOULD use this field to indicate the size of the message body to be transferred.
    Hence the implementation of HttpURLConnection is that it creates a socket connection with the remote server and gets the Response Header. It reads the value of the COntent-Length field from the header. If the content-Length is ) then it assumens there is nothing more to read and hence reads nothing.
    In your implementation you are using the input stream of the HttpURLConnection and not making a direct socket connection with the remote server.
    It is due to this reason that when internally HttpURLConnection getrs the respose Header it fonds the value of the Content-Length as 0 and hence stops reading and consequntly your application also cannot read.
    I Hope this answers your query.

  • Setting Timeout  in URLConnection/HttpURLConnection

    Hi all,
    I am trying to open a connection a website using the java.net.HttpURLConnection.
    Please tell me what is the default timeout (how much time it will wait for getting reply ) and how we can change the
    default value. Please help me.
    Thanks in advance.

    This seems to be what you are looking for.
    [http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLConnection.html#setReadTimeout%28int%29|http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLConnection.html#setReadTimeout%28int%29]

  • On Windows 7 HttpURLConnection.openConnection() throws IOException

    Hi Team,
    In our application we have a to create httpURLCOnnection (url.openConnection())which works fine on Windows XP but throws IOException on Windows7. Does anybody know which settings need to be enabled on windows 7 to resolve this issue?
    Any response would be appreciated. Thanks in Advance.

    Hello Team,
    I have a specific exception which I get when trying to open a url on Windows 7 with IIS authentication enabled. We get exception when trying to get response code of HTTP Connection
    java.io.IOException: Authentication failure
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.net.HttpURLConnection.getResponseCode(Unknown Source)
    Same code works find on windows XP. Do I need to do any specific settings on Windows7 to work this?
    Thanks in Advance.

  • Time Machine stops writing to drive at 380 of 390 GB

    I'm using Time Machine to do a full backup of my computer for the first time. I have a WD MyBook Pro Edition II set as a striped 1T raid connected via FW800 with no other FW devices connected. After 4 hours the progress bar stopped at 380 of 390 GB and claims to be still backing up files. However it has been at that point for almost an extra hour now. Activity monitor shows no disk activity and I can't even see Time Machine listed as a process. I tried stopping TM by clicking on the "x" and it claimed it was stopping, but after a few minutes it reverted to "backing up XXXXX items with no increase in the number of bytes transfered. Force Quit does not list TM.
    What do I do now?
    Thanks in advance!

    +I looked at my external disk and it looks like it is one partition and of the right format already. I verified the disk - everything appears fine. Could I be mislead by what I see in Disk Utility? Should I go through these gyrations anyhow?+
    It wouldn't hurt but highly doubtful that it would help. Start a new topic explaining what specific problem you are having and what you have tried to do to fix it, if anything. There also might be a hint or two in Console about why Time Machine is not working properly for you. Launch Console which is in Applications > Utilities. Choose All Messages in the left pane of Console and type in "backupd" in the search window without the quotes to see the Time Machine log. Post any errors or complaints that show up in the log.
    +By the way, can you copy a Time Machine backup database from one computer to another and back again after an erase and maintain its integrity?+
    I'm not sure what you mean be copying from one computer to another. If you mean copying the Time Machine backups from one disk to another it's been a mixed bag using either Disk Utility or Carbon Copy Cloner going by the posts from people who have tried it. One would expect that using the Restore function in Disk Utility ought to work.

Maybe you are looking for

  • Registering Adobe Dreamweaver CS6?

    Hi Everyone, I forgot to register my product when downloading. Now I want to register my product. I'm using adobe dreamweaver cs6. How would I go about registering my product? Thanks

  • Re-sizing flash (.SWF) file in Dreamweaver?

    Hi there, I was wondering if their is a way to actually re-size a .swf in Dreamweaver. When my site is published online it takes approx 1 minute to load the first page. Stupid question but this is my first flash web site, so please bare with me. When

  • Sales order line item cannot be rejected as service order has been archived

    Iam trying to reject a line item in a sales order with a "AP cancel line item" reason, but it does not allow me saying that the service order does not exist. The service order has been archived earlier. Is there any solution or workaround of this pro

  • Obscure Hot Keys

    Flash comes with a list of hot keys, but there are a few I've stumbled into that I haven't seen documented anywhere else. They've saved me a lot of time, so if you haven't heard of them, they might help you, too. I'm sure a lot of you know them, but

  • E61 and system fonts

    What is the defualt fonts for the E61? Many thanks