1

I have created a very simple php web service, which is not having the WSDL. I find a way to call it from the java application.

String endpoint = "http://localhost/webser/simple_server.php";  
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress( new java.net.URL(endpoint) );
            call.setOperationName( new QName("urn://tyler/req") );
            String ret=(String)call.invoke("readfat",new Object[]{});
            System.out.print(ret);

It works fine and gives the output. But it need external jar files like axis1-3.jar,commons-discovery, commons-logging.....etc. I want to know whether there is a way to consume a web service without any external dependancies?. My actual need is to consume the web service from an Applet. So I cannot tolerate the external depepndancies. can JAX-WS be used for this purpose?

JEMSHID56
  • 305
  • 5
  • 16
  • You can use HttpUrlConnection like explained in this post here: http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests. – gerrytan Mar 30 '13 at 07:56
  • Thank you gerrytan.... Its a useful Link – JEMSHID56 Mar 30 '13 at 08:42

1 Answers1

2

If you want to call a web service if you can simply make the HTTP requests yourself.

If you don't want any external dependencies the class to use from the standard library is java.net.HttpURLConnection.

This question has a very detailed answer showing you how to do this.

Community
  • 1
  • 1
David Webb
  • 190,537
  • 57
  • 313
  • 299
  • WOW!! Thank You! You made it so simple. I have thinked a lot. But if I add a few lines in my WS.php, using java.net.HttpURLConnection, it will work like charm. Its a wise answer Dave and gerrytan – JEMSHID56 Mar 30 '13 at 08:54