如何配置Eclipse以使用Web服务?

时间:2011-02-26 16:25:53

标签: eclipse axis2

我正在尝试生成客户端代码以与Web服务进行交互,但我无法确定可以对服务器进行哪些过程调用。我认为在Eclipse中构建它将是一个很好的捷径,以帮助我理解API,但我真的不知道从哪里开始eclipse。现在我正在使用axis2并从命令行运行wsdl2java:

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

这会生成我需要的所有存根,但我需要将我的凭据添加到标题中,示例代码(下面)给出了相应的函数Header1()但这不正确我需要找到正确的函数

//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 (me@myfirm.com) to the Username element
h.setUsername("me@myfirm.com");
//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);

1 个答案:

答案 0 :(得分:1)

当使用现有的WSDL时,我总是使用SoapUI进行快速原型设计并查看该服务提供的方法 - 该软件有一个免费的社区版本。而且,它还有一个Eclipse plugin,与独立版本相同。

相关问题