• Post Reply Bookmark Topic Watch Topic
  • New Topic

SOAP Client using Java Sockets

 
Kiran Kumar
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I am trying to write a SOAP client using Java Sockets which communicates with a SOAP Server. The incomplete Client looks something like this..
------------------------------------------------
public class CalcClientHttp {
public static void main(String[] args) throws Exception {
//URL url = new URL("http://host:8080/soap/servlet/rpcrouter");

Socket socket = new Socket(host:8080/soap/servlet/rpcrouter, 80);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out.write("POST ... .rest of SOAP request");
out.flush();
------------------------------------------------
I am not able to communicate with the SOAP server. All I am trying is to make a Client SOAP freely communicating with a SOAP server.
That way my simple client is much much faster than a SOAP Client as more than 50% of my client execution is preparing XML doc and sending it over HTTP. To avoid this, I want to bypass this and do this using Sockets.
If someone has made a previous attempt at this, please please get in touch with me. Any help would be appreciated.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand your situation, there is no reason to go to all this trouble - rpcrouter is expecting a Http connection, you will either have to re-create the code that a URLConnection performs or just use a URLConnection. (Or write your own replacement for rpcrouter.)
It isn't the HTTP sending that is gobbling up the time, it is the DOM creation and serialization. This looks like Apache SOAP (which was current when I wrote my book) - it is NOT written for speed. It creates lots of objects for one thing. The server end is also very inefficient.
You don't have to do that if your client message is relatively simple. All you need is a text skeleton of the SOAP message that you plug a few values into and send. You could use my snoop utility to spy on the client-server conversation. Find it at www.wbrogden.com - click on the SOAP book reference, the utility download is at the bottom of the SOAP book page.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!