title: Java unable to act as client for service
body: <p>So I have created a service on JDeveloper with socket adapter where a message is read from. I have followed the steps mentioned in the following link for that: <a href="https://shrikworld.blogspot.com/2014/11/demystifying-oracle-socket-adapter.html" rel="nofollow noreferrer">https://shrikworld.blogspot.com/2014/11/demystifying-oracle-socket-adapter.html</a>
  However the problem is that when i create the java class to test the service, i get an error.</p>
  
  <p>I have been trying to figure out what the issue is but i cant find anything useful on this. Here is a description of the SocketAdapter in my weblogic console:</p>
  
  <pre><code>Host: localhost
  KeepAlive: true
  EnableSDP: false
  backlogQueue: 0
  port: 12110
  SSLEnable: false
  NeedClientAuthentication: false
  Timeout: 1000
  </code></pre>
  
  <p>Here is my java class:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.IOException;
  
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  
  import java.net.Socket;
  
  public class Client {
      public static void main(String[] args) {
          try {
              Socket socket;
              final String HOST = "localhost";
              final int PORT = 12110;
              try {
                  socket = new Socket(HOST, PORT);
              } catch (IOException ioe) {
                  System.out.println("&gt;&gt;&gt;");
                  System.out.println(ioe.getMessage());
                  System.out.println("&gt;&gt;&gt;");
                  throw ioe;
              }
              System.out.println("sending data: EmpDetails;");
              OutputStream os = socket.getOutputStream();
              byte[] b = "fn111111ln111111232007-01-01100\nfn211111ln211111232007-11-01200\nfn311111ln311111232007-12-01300".getBytes();
              for (int i = 0; i &lt; b.length; i++) {
                  os.write(b[i]);
              }
              os.flush();
              socket.shutdownOutput();
              System.out.println("receiving data");
              BufferedReader soc_in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
              String successCode = soc_in.readLine();
              System.out.println("Success Code: " + successCode);
              socket.close();
          } catch (IOException ioe) {
              ioe.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>and here is the error I get when I try running the code:</p>
  
  <pre><code>java.net.ConnectException: Connection refused: connect
      at java.net.DualStackPlainSocketImpl.connect0(Native Method)
      at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:589)
      at java.net.Socket.connect(Socket.java:538)
      at java.net.Socket.&lt;init&gt;(Socket.java:434)
      at java.net.Socket.&lt;init&gt;(Socket.java:211)
      at SocketAdapter.Client.main(Client.java:18)
  </code></pre>