spinlock
spinlock

Reputation: 3947

How do you configure Eclipse to work with Web Services?

I'm trying to generate client code to interact with a web service but I'm having trouble figuring out which procedure calls I can make to the server. I thought building this in Eclipse would be a good short-cut to help me understand the API but I don't really know where to start with eclipse. Right now I'm using axis2 and running wsdl2java from the command line:

wsdl2java.sh -uri http://www.xignite.com/xQuotes.asmx?WSDL -s -ap -o xignite

This generates all of the stubs that I need but I need to add my credentials to the header and the sample code (below) gives the appropriate function as Header1() but this is not correct and I need to find the right function.

//Instantiate the service
XigniteQuotesXigniteQuotesSoapStub stub = new XigniteQuotesXigniteQuotesSoapStub();
//Instantiate the objects that will let you build the SOAP Header
Header1 header = new Header1();
//Create the Header
Header h = new Header();
//Assign your email address ([email protected]) to the Username element
h.setUsername("[email protected]");
//Set the password
h.setPassword("");
//Set the SOAP header
header.setHeader(h);
//Create the arguments needed for the call
GetQuotes getQuotes = new GetQuotes();
getQuotes.setSymbol("msft,aapl");
//Make the call with the arguments and the header
GetQuotesResponse response = stub.GetQuotes(getQuotes, header);

Upvotes: 0

Views: 411

Answers (1)

Axel Knauf
Axel Knauf

Reputation: 1683

When using an existing WSDL, I always used SoapUI for quick prototyping and seeing what methods the service provides - there is a free community version of the software. And, there is also an Eclipse plugin for it which does the same as the standalone version.

Upvotes: 1

Related Questions