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

9.2. Calling a GLUE Service from an ApacheSOAP Client

Since we already have a GLUE service running, let's try to access it with a client written using Apache SOAP. It's nice of the service to publish WSDL, but Apache SOAP clients can't do anything with that data. So we'll have to derive whatever information we need from the WSDL ourselves. Before we get into that, though, let's write a quick application that tries to call the getHeadlines method of the urn:CorpDataServices service.

First we need to determine the proper URL. When we were calling Apache SOAP services, the URL pointed to the rpcrouter servlet. In this case, a GLUE server application is hosting the service, so the URL we want is http://mindstrm.com:8004/glue/urn:CorpDataServices.

With pure Apache SOAP examples, we always called call.setTargetObjectURI( ) and passed the service name as the parameter, but here we've already specified the service name in the URL. It turns out that this is the right choice, but we've got to call setTargetObjectURI( ) with some value or we'll get a client-side error. GLUE doesn't appear to care what value we use, since we've already arrived at the target endpoint, so we can just use any nonempty string when we call setTargetObjectURI( ). I'm inclined to use the service name again, but it seems to work no matter what we do. Here's the code for the Apache2Glue application:

package javasoap.book.ch9; import java.net.*; import java.util.*; import org.apache.soap.*; import org.apache.soap.rpc.*; ...

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