gpt4 book ai didi

java - 创建 Java Web 服务客户端

转载 作者:太空宇宙 更新时间:2023-11-04 08:23:03 24 4
gpt4 key购买 nike

我正在尝试研究如何访问外部网络服务。我在 eclipse 中为以下 Web 服务创建了一个 Web 服务客户端:

http://www.webservicex.net/ws/WSDetails.aspx?WSID=9&CATID=2

我尝试使用以下代码访问此网络服务:

public static void main(String[] args) {
try{
StockQuoteLocator locator = new StockQuoteLocator();
locator.setEndpointAddress("StockQuoteSoap", "http://www.webservicex.net/stockquote.asmx");
StockQuoteSoapStub stock = new StockQuoteSoapStub(locator);
System.out.println(stock.getQuote("TEVA"));
} catch (Exception e){
e.printStackTrace();
}
}

但我不断收到错误:

06/02/2012 11:29:51 org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
AxisFault
faultCode: {http://xml.apache.org/axis/}Server.NoEndpoint
faultSubcode:
faultString: No endpoint
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}exceptionName:org.apache.axis.NoEndPointException
{http://xml.apache.org/axis/}stackTrace:No endpoint
at NET.webserviceX.www.StockQuoteSoapStub.getQuote(StockQuoteSoapStub.java:93)
at Main.main(Main.java:17)

{http://xml.apache.org/axis/}hostname:MICHALEDR-DTW7

No endpoint
at NET.webserviceX.www.StockQuoteSoapStub.getQuote(StockQuoteSoapStub.java:93)
at Main.main(Main.java:17)

你能帮我解决这个问题吗?

最佳答案

它清楚地表明您的类路径中缺少这些类。

添加activation.jarjavamail.jar到你的类路径。

关于java - 创建 Java Web 服务客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9158068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com