O'Reilly logo

Java and SOAP by Robert Englander

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.4. Writing Service Clients

In the next few sections, we'll write some Java code that invokes methods on the services we've exposed in both Apache SOAP and GLUE. For now, we won't mix and match technologies — we'll use Apache SOAP APIs to call an Apache SOAP server, and GLUE APIs to call a GLUE server.

So what about interoperability? One of the most important aspects of SOAP as a wire protocol is that your choice of implementation should not prohibit you from communicating successfully with other SOAP implementations. However, there are still some problems with SOAP interoperability. Some technologies are better at it right now than others, and in some cases you have to jump through a few hoops to make different SOAP technologies communicate properly with each other. So let's put off this subject until Chapter 9, where we'll cover these issues in detail.

4.4.1. Calling the Service with Apache SOAP

Now that we have a service up and running, let's write some Java code that acts as a client of the service. Here's a simple Java application that invokes the getCount method of the urn:CallCounterService on our Apache SOAP server:

package javasoap.book.ch4; import java.net.*; import org.apache.soap.*; import org.apache.soap.rpc.*; public class GetCountApp { public static void main(String[] args) throws Exception { URL url = new URL( "http://georgetown:8080/soap/servlet/rpcrouter"); Call call = new Call( ); call.setTargetObjectURI("urn:CallCounterService"); call.setMethodName("getCount"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required