Java Nio and http proxy

Hello,
I would send a http request through a http proxy with a Nio Client. So I wrote by hand the
http request :
buffer.append("HTTP/1.1\n");
buffer.append("Content-type: text/xml\n");
Then I send this request with a Nio Client but the request doesn't pass.
Can you help me ?

I use tcp to send my request with a nio Client. The header of my http request :
StringBuffer buffer = new StringBuffer();
buffer.append("POST ");
String path = "/";
buffer.append(path + " ");
buffer.append("HTTP/1.1\r\n");
buffer.append("Content-type: text/xml\r\n");
buffer.append("Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n");
buffer.append("Host: 10.194.55.23:80\r\n");
buffer.append("Connection: keep-alive\r\n");
buffer.append("Content-Length: 0\r\n");
buffer.append("\r\n");

Similar Messages

  • Nio and http proxy

    I want to use http proxy in nio.but i can't find any methods in socketChannel.(if use socket, i could use such code do impl this
    Socket socket = new Socket(new Proxy(......));
    socket.connect(serverAddress); now i want to set a http proxy to SocketChannel, but i found it's impossiable to construct a SocketChannel from a pre exist socket.
    how to use proxy in nio.
    thanks all.

    I use tcp to send my request with a nio Client. The header of my http request :
    StringBuffer buffer = new StringBuffer();
    buffer.append("POST ");
    String path = "/";
    buffer.append(path + " ");
    buffer.append("HTTP/1.1\r\n");
    buffer.append("Content-type: text/xml\r\n");
    buffer.append("Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n");
    buffer.append("Host: 10.194.55.23:80\r\n");
    buffer.append("Connection: keep-alive\r\n");
    buffer.append("Content-Length: 0\r\n");
    buffer.append("\r\n");

  • Java.nio and databases

    Please, need help.
    I'm using java.nio to get large files contents (txt) and need to put these data into MSSQL SERVER 2000 database tables. NIO have capabilityies to get data and transfer directly to the tables? If so, how can i do it?
    Thanks a lot
    Aloisio

    ChuckBing, i'm connected with database trough JDBC yet and i can retrieve data meaning my connection is OK.
    I'm able to read data from a txt file (250mb large) trough MappedByteBuffer and write into another with the same size and content. It's working fine.
    My question is if i can read the txt file and, instead write the data into another txt file, put these data into a table.
    Thanks for your reply

  • WWSAPI - Cannot connect to web service via SSL and HTTP proxy authentication with NTLM, errorCode 0x803d0016, HTTP status 407

    Hi,
    I built a web service client using WWSAPI. The connection works via SSL (without HTTP proxy) and it works with SSL and proxy with basic authentication as well. When I try to connect using a proxy with NTLM authentication, then I get the errorCode
    0x803d0016, HTTP status "407 (0x197)", "Proxy Authentication Required".
    In WireShark I see only one HTTP request to connect to the proxy with NTLM Message Type: NTLMSSP_NEGOTIATE. The HTTP Response returns Status 407 and the connection ist closed. Comparing this to Internet Explorer - the Connection is not closed and
    a second request with NTLMSSP_AUTH is sent.
    Why doesn't it make the complete NTLM handshake? Why wasn't sent the NTLMSSP_AUTH directly?
    I oriented in the HttpCalculatorWithKerberosOverSslClientExample.
    Using WS_HTTP_HEADER_AUTH_SECURITY_BINDING,
    WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_SCHEME was set to WS_HTTP_HEADER_AUTH_SCHEME_NTLM, WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_TARGET to WS_HTTP_HEADER_AUTH_TARGET_PROXY. I tried WS_DEFAULT_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE but also WS_STRING_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE.
    Any idea?
    Thanks

    Hi,
    I built a web service client using WWSAPI. The connection works via SSL (without HTTP proxy) and it works with SSL and proxy with basic authentication as well. When I try to connect using a proxy with NTLM authentication, then I get the errorCode
    0x803d0016, HTTP status "407 (0x197)", "Proxy Authentication Required".
    In WireShark I see only one HTTP request to connect to the proxy with NTLM Message Type: NTLMSSP_NEGOTIATE. The HTTP Response returns Status 407 and the connection ist closed. Comparing this to Internet Explorer - the Connection is not closed and
    a second request with NTLMSSP_AUTH is sent.
    Why doesn't it make the complete NTLM handshake? Why wasn't sent the NTLMSSP_AUTH directly?
    I oriented in the HttpCalculatorWithKerberosOverSslClientExample.
    Using WS_HTTP_HEADER_AUTH_SECURITY_BINDING,
    WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_SCHEME was set to WS_HTTP_HEADER_AUTH_SCHEME_NTLM, WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_TARGET to WS_HTTP_HEADER_AUTH_TARGET_PROXY. I tried WS_DEFAULT_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE but also WS_STRING_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE.
    Any idea?
    Thanks

  • Java NIO and sockets in 1.4.1FCS

    Hi,
    I have built a client server system using the new 1.4 java.nio packages. In 1.4 everything worked fine, yet in 1.4.1 FCS it definitely does not. The process is as follows.
    Everything work in non-blocking mode:
    - Server receives connection and accepts it, the new SocketChannel is put in non-blocking mode and registered with the same selector as the server.
    - New SocketChannel waits for data from the client so it waits for OP_READ from the selector. All it gets is OP_WRITE, OP_CONNECT. With 1.4 it received OP_READ, OP_WRITE.
    I tried adding a call to finishConnect, but that didn't help.
    Anyone have any thoughts about this?
    Thanks,
    Mike.

    The code in the bug report is incorrect. The key will of course always be writable if you do not write anything to the socket! And since it is writable the readable part of the code will never be executed (its in an else-statement). When you are not interested in the OP_WRITE, change the ops on the selection key.

  • DAP and http proxy authentication

    I have a ASA firewall with http proxy authetication and now i configure DAP for Anyconnect with AD .I disable the "Default Dynamic Access Policy"  proxy authentication fail .Someone knows how to configure the DAP for http proxy authentication ?
    best regards

    Still nothing about it. I've also posted to another threads with similar problems:
    http://discussions.apple.com/message.jspa?messageID=8165122#8165122
    http://discussions.apple.com/message.jspa?messageID=8165120#8165120
    http://discussions.apple.com/message.jspa?messageID=8165118#8165118
    http://discussions.apple.com/message.jspa?messageID=8149758#8149758
    As I said before, while I've had OS 1.1.4, everything was normal. It began when I upgraded to 2.0.2 and after to 2.1. I also double checked if the TI here changed the policies, and they assured me they don't.
    Several other users with 2.x are also reporting the same trouble. As far as now, I've came across a post suggesting me to install a local http proxy on the phone, but I don't think it's gonna work.
    Let's keep this thread alive!

  • Announcement: Java NIO Framework

    Hi all,
    After reading Ron Hitchen's book "Java NIO" and watching his presentation "How to Build a Scalable Multiplexed Server With NIO" at the 2006 JavaOne Conference, I implemented a framework based on his ideas.
    Here is the website: http://nioframework.sourceforge.net/
    I would be very glad if you could take a look and tell me what you think about it.
    Regards and thanks for your input!
    Ronny Standtke
    PS: I will add dukes to this topic and spend it for contributors (found bugs, hints, ...).

    Finally I found the time to write some benchmark programs for the NIO Framework and take a look at the MINA API.
    If you download the latest NIO Framework release you can run the plaintext benchmark as follows:
    Start the benchmark server (this is just the echo server without any session debugging output or logging) with the following command:
    java -cp nio_framework-0.9.3_all.jar ch.unifr.nio.framework.examples.BenchmarkServer 8080
    Then start the benchmark client with the follwing command:
    java -cp nio_framework-0.9.3_all.jar ch.unifr.nio.framework.examples.BenchmarkClient localhost 8080
    On my machine the resulting bandwidth is around 80 MB/s.
    And now to MINA:
    I used the very simple echo server example from the MINA project and just removed the logger from the chain. You may download this package from here (it includes all relevant source code):
    http://nioframework.sourceforge.net/mina_echo_server.jar
    You can start this server with the following command:
    java -jar mina_echo_server.jar
    If I run my BenchmarkClient against the MINA echo server the resulting bandwidth is only around 20 KB/s!? That is about 4000 times slower.
    Is MINA really THAT slow? I seriously doubt that. Are there any stops that I have to pull to get a higher bandwidth with MINA?

  • Help "ascending" to Java NIO

    Hello there.
    I've been using Java for quite some time, but the few really networked client/server applications I have used, have used java.io and java.net. Now, even I have heard the rumours about Java NIO, and I am curious. I have tried reading up and down the API on java.nio.* , but I must say I am still kind of confused.
    Basically, I am looking for some example code, or a thorough explanation of how all the classes and components come together to form efficient asynchronous non-blocking I/O.
    What I picture is a server over TCP/IP meant to handle 100+ clients, written with an emphasis on performance. Think MMORPG, I guess (no no, I am not ambitious enough to want to write one, but I can imagine that gives a good analogy of how I would have the communication set up). The server needs to quickly figure out which clients need to be handled at any given time, with as little overhead or reduntant iteration as possible.
    Ok, I am asking alot perhaps.. I just wonder if anyone could offer links to example source-code, write something to show me, or basically just try to explain to me how this all works.
    I would be very very grateful if anyone stepped up to the plate.
    Thanks,
    -Terje

    Take a look at my thread Taming the NIO Circus. It starts with simple examples of a single thread echo server and a swing client.

  • Http Proxy and Java Web Start 1.4.2_08

    Hi All,
    I'm confused as to how Java Web Start is supposed to work with an HTTP proxy. I'm testing an application in an environment which has an http proxy.
    Our application starts successfully with Web Start but the application is failing to connect to URLs. I have dumped the properties right when the app starts and proxyHost, proxyPort, http.proxyHost, http.ProxyPort are all set correctly. But every attempt to connect to URLs timeout.
    Note that running under 1.5, I get the value of the
    javaplugin.proxy.config.list property and use it to set the properties http.proxyHost and http.proxyPort. Then I am able to connect successfully to the same URLs which failed in 1.4.2_08 ( also fails
    with 1.4.2_03).
    Can someone please help me understand what's wrong here?
    Many thanks,
    Jason

    Actually, what I observed, in 1.4.2_08, is that the https.proxy* properties are being set. The http.proxy* properties are not set.
    in 1.5.0_04 none of the properties are set except for
    javaplugin.proxy.config.list, which I use to set http.proxyHost and http.proxyPort.

  • Java NIO locking and NTFS network resources

    Hi all - just ran into a really nasty situation and I was wondering if anyone else has hit it and might have some suggestions.
    Platform: JRE 1.4_02 on a Win XP machine
    The following test code locks a file, then copies it to another location using NIO.
    When I run it with source path on my local drives (C), it works fine. If I run it with source path on a network shared resource, it fails with an IOException with description 'Error performing inpage operation'.
    If I disable the lock immediately before the copy operation, it works fine.
    My conclusion is that there is something about the NIO locking implementation that prevents it from working properly with NTFS volumes on other hosts. Can this be right? I've found the following bug report:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4774175
    but this seems like a huge problem that would prevent folks from using NIO in many, many applications. Maybe I'm wrong on something here...
    Anyway, here's the test code:
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    import java.nio.channels.FileChannel;
    import java.nio.channels.FileLock;
    * Created on May 28, 2004
    * (c) 2004 Trumpet, Inc.
    * @author kevin
    public class test {
         private void createFile(File f) throws IOException{
              FileOutputStream os = new FileOutputStream(f);
              for(int i = 0; i < 10; i++){
                   os.write(i);
              os.close();
         public test() {
              boolean testWithReleasingLockPriorToCopy = false;
              final File f1= new File("w:/temp/test2.lok");
              final File f2 = new File("w:/temp/test.lok");
              f1.delete();
              f2.delete();
              try {
                   createFile(f1);
                   RandomAccessFile raf1 = new RandomAccessFile(f1, "rw");
                   RandomAccessFile raf2 = new RandomAccessFile(f1, "rw");
                   FileChannel ch1 = raf1.getChannel();
                   FileChannel ch2 = raf2.getChannel();
                   FileLock flock1 = ch1.lock();
                  if (!f2.getParentFile().exists() && !f2.getParentFile().mkdirs())
                       throw new IOException("Unable to create directories for destination file '" + f2 + "'");
                  if (testWithReleasingLockPriorToCopy)
                       flock1.release();
                   ch1.transferTo(0, raf1.length(), ch2);
                   raf1.close();
                   raf2.close();
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
         public static void main(String[] args) {
              test t = new test();
    }Does anyone have any pointers here? I need to be able to exclusively lock a file on a network drive (preventing any other applications from opening it), then make a copy of it. I can't use regular stream operations, because the lock prevents them from working properly (it appears that, once you grab a file lock using NIO, the only way your application can use the file is via the NIO operations - using stream operations fails...).
    Thanks in advance for any help!
    - Kevin

    i've run into the same problem recently, channels working fine for local file locking, but when you turn to the network, they fail to accurately handle locks.
    i ended up writing a jni utility to ship with my java application that locks files using native windows calls.
    my .c file ends up looking something like this:
    JNIEXPORT jint JNICALL Java_Mapper_NativeUtils_LockFile
    (JNIEnv *env, jobject obj, jstring filename)
    const char* ntvFilename = (*env)->GetStringUTFChars(env, filename, 0);
    int retVal = (int)CreateFile
    ntvFilename
    , GENERIC_WRITE
    , FILE_SHARE_READ
    , 0
    , OPEN_EXISTING
    , FILE_FLAG_SEQUENTIAL_SCAN
    , 0
    //add code to throw java exceptions based on retVal
    if (retVal == (int)INVALID_HANDLE_VALUE)
    return retVal;
    (*env)->ReleaseStringUTFChars(env, filename, ntvFilename);
    return retVal;
    JNIEXPORT jboolean JNICALL Java_Mapper_NativeUtils_UnlockFile
    (JNIEnv *env, jobject obj, jint handle)
         CloseHandle((void *)handle);
    return 1;
    it's a little shy on the error checking side, but it provides support for network file locking that java seems to lack.

  • About Java mapping and java proxy

    Hi
    Iam new to Xi and basically iam an ABAPER.When iam dooing mappinps or proxies i cant able to understand the java pari cant (javamapping and java proxies) .I need some notes on java mapping and java proxy which is easy to do.And why do we use this java mapping or java proxy particularly when we r having abap mappipng and abap proxy.
    thanks in advance

    Hi,
    refer
    Java Mapping
    SAP Network Blog: Java Mapping (Part I)
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    Java Mapping in XI
    https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=java+mapping&adv=false&sortby=cm_rnd_rankvalue#
    Runtime Environment (Java Mappings) (SAP Library - Partner Connectivity Kit)
    http://help.sap.com/saphelp_nw04/helpdata/en/bd/c91241c738f423e10000000a155106/frameset.htm
    Java Mapping (SAP Library - Partner Connectivity Kit)
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    SAP Network Blog: Testing and Debugging Java Mapping
    /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    SAP Network Blog: Implementing a Java Mapping in SAP PI
    /people/carlosivan.prietorubio/blog/2007/12/21/implementing-a-java-mapping-in-sap-pi
    "JAVA MAPPING", an alternate way of reading a CSV file
    /people/rahul.nawale2/blog/2006/07/18/java-mapping-an-alternate-way-of-reading-a-csv-file
    SAP Network Blog: XI Java Mapping Helper (DOM)
    /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    Java Proxy
    Java Proxy Objects (SAP Library - SAP Exchange Infrastructure)
    http://help.sap.com/saphelp_nw04/helpdata/en/c5/7d5e3c754e476ee10000000a11405a/frameset.htm
    Accessing Active Directory through Java Proxy on SAP Exchange Infrastructure 3.0
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10716e9f-23d7-2a10-8c8c-d2665615f8fc
    Thanks
    Swarup

  • Java and abap proxy ganeration

    hi all,
    i am new to proxies,i need the complete scenarios for java proxy generation and abap proxy generation.
    regards,
    AVR

    help yourself;
    ABAP
    Client Proxy (Sender Proxy)- /people/ravikumar.allampallam/blog/2005/03/14/abap-proxies-in-xiclient-proxy
    Server Proxy (Receiver Proxy)- /people/siva.maranani/blog/2005/04/03/abap-server-proxies
    Java
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7d4db211-0d01-0010-1e8e-9b07fc2113ab
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/a068cf2f-0401-0010-2aa9-f5ae4b2096f9
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f272165e-0401-0010-b4a1-e7eb8903501d

  • Java Proxy and ABAP Proxy

    hi,
    can any one send me some documents on Java Proxy and ABBAP Proxy
    regards,
    John

    hi,
    Proxies are nothing but a mechanism to shift the application logic from the XI server onto the sender or reciever system so as to reduce the effort on the side of XI.Depending upon where the proxies are generated ,it is differentiated as client proxy ( sender ) and server proxy ( receiver ) .In R3 system having WAS 6.2 and above its already has an inbuilt small IE so the proxy generation is favoured and possilbe,for more on this please go thru the following links
    Proxies: are interfaces which will get executed in the application system. They can be created only in the system from message interfaces using the proxy generation functions.
    The biggest advantage of the proxy is that it always by passes the Adapter Engine and will directly interact with the application system and Integration engine - so it will and should give us a better performance.
    The literal definition of a proxy is an object / process authorized to act for another; an agent or a substitute. In simpler terms, proxies in the XI context are objects used to encapsulate the creation (from a sender system) or parsing of XML (at a receiver system) as well as the communication with the relevant runtime components required to send or receive those messages. The Proxy Runtime controls these objects / processes, and can itself be controlled by the applications it communicates with.
    The Proxy currently has the following components available:
    1. ABAP Proxy – Communication using XI or Web Services
    2. Java Proxy– Communication using XI (J2EE)
    For further reference, visit the following sites,
    To test a connection - /people/vijaya.kumari2/blog/2006/01/26/how-do-you-activate-abap-proxies
    Client Proxy - /people/ravikumar.allampallam/blog/2005/03/14/abap-proxies-in-xiclient-proxy
    Server Proxy - /people/siva.maranani/blog/2005/04/03/abap-server-proxies
    Testing proxy - /people/stefan.grube/blog/2006/07/28/xi-debug-your-inbound-abap-proxy-implementation
    JAVA Proxies:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a068cf2f-0401-0010-2aa9-f5ae4b2096f9
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f272165e-0401-0010-b4a1-e7eb8903501d
    ABAP Proxies:
    /people/sap.user72/blog/2005/12/13/integration-builders-through-proxy-server-part--2
    /people/ravikumar.allampallam/blog/2005/03/14/abap-proxies-in-xiclient-proxy
    /people/arulraja.ma/blog/2006/08/18/xi-reliable-messaging-150-eoio-in-abap-proxies
    /people/stefan.grube/blog/2006/07/28/xi-debug-your-inbound-abap-proxy-implementation
    /people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments
    /people/sukumar.natarajan/blog/2007/01/07/how-to-raise-alerts-from-abap-proxy
    /people/sravya.talanki2/blog/2006/07/28/smarter-approach-for-coding-abap-proxies
    ON SDN TV
    https://www.sdn.sap.com/irj/sdn/advancedsearch?query=abap%20proxy%20xi&cat=sdn_all&start=11#

  • J2ME and java.nio

    I'm not sure which forum this should go in so applogies if I got it wrong.
    I would like to use the java.nio package from JDK1.4 with the J2ME. Is this possible in any way?
    cheers
    Andrew

    I'm not sure which forum this should go in so
    applogies if I got it wrong.
    I would like to use the java.nio package from JDK1.4
    with the J2ME. Is this possible in any way?this topic should be post at
    CLDC and MIDP
    http://forum.java.sun.com/forum.jsp?forum=76
    or
    K Virtual Machine (KVM)
    http://forum.java.sun.com/forum.jsp?forum=50
    CLDC 1.0 and MIDP 1.0 doesn't include java.nio
    please go to
    http://java.sun.com/j2me/docs/
    two documents will be useful
    CLDC Specification, V1.0
    MIDP 1.0 Specification, Final (JSR 37)

  • HTTPS and a Proxy server?

    Does the plugin-in still not work with HTTPS and a proxy server?
    From plug-in docs -
    "Java Plug-in supports http, ftp, gopher and SOCKS v4 protocols through the proxy server. Currently, Java Plug-in does not support https (SSL). "

    Hello
    I am making HTTPS calls from within my applet code and this works fine using the basic Java Plug-in support for HTTPS.
    This means my code basically does:
    URL url = new URL("https://myhost.com/servlet/Test");
    URLConnection conn = url.openConnection();
    etc..
    We are using Java 1.4.2. I've read in the "How HTTPS Works in Java Plug-in" for 1.3, that the plugin uses the browsers API for making HTTPS connections. Is this still the case for 1.4?
    My basic problem is that it all works fine if the browser is NOT configured to use a proxy server. If a proxy server is configured we get the following Exception in the client:
    java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 400 Bad Request ( The data is invalid. )"
    I have read that "Sun's Java Secure Socket Extension (JSSE) library allows you to access a secure Web server from behind a firewall via proxy tunnelling. However, JSSE expects the proxy's reply to the tunnelling request to begin with "HTTP 1.0"; otherwise, it throws an IOException" (http://www.javaworld.com/javatips/jw-javatip111_p.html)
    The article talks about using the JSSE library but it seems to be assuming the client is an application not an applet.
    How do I use JSSE from within an applet if all the proxy information I seem to need to set in the JSSE code is held by the browser?
    Will JSSE support proxies returning responses beginning HTTP 1.1 in the future?
    Any help on this would be greatly appreciated.
    Many thanks
    mark

Maybe you are looking for