gpt4 book ai didi

java - 从简单的 Java 客户端调用 Web 服务

转载 作者:行者123 更新时间:2023-12-04 06:20:39 24 4
gpt4 key购买 nike

在 Eclipse 中,我在客户端编写此代码,从 wsdl 文件生成...

TravelAssistServicesStub t = new TravelAssistServicesStub();
ConversionRateByCountry c = new ConversionRateByCountry();
c.setCountry("India");
c.setUser_Id("satya");
ConversionRateByCountryResponse ccy = t.conversionRateByCountry(c);

System.out.println("Conversion: " + ccy.get_return());

...我得到以下异常:
java.lang.NoClassDefFoundError: org/apache/http/HttpResponseFactory
at org.apache.axis2.transport.http.SimpleHTTPServer.init(SimpleHTTPServer.java:113)
at org.apache.axis2.engine.ListenerManager.init(ListenerManager.java:74)
at org.apache.axis2.context.ConfigurationContext.getListenerManager(ConfigurationContext.java:692)
at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:163)
at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:143)
at com.travelassist.services.TravelAssistServicesStub.<init>(TravelAssistServicesStub.java:159)
at com.travelassist.services.TravelAssistServicesStub.<init>(TravelAssistServicesStub.java:145)
at com.travelassist.services.TravelAssistServicesStub.<init>(TravelAssistServicesStub.java:196)
at com.travelassist.services.TravelAssistServicesStub.<init>(TravelAssistServicesStub.java:188)
at com.tcs.client.login.LoginClient.main(LoginClient.java:37)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpResponseFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

最佳答案

您缺少 apache httpcomponents jar。确保它在运行时位于您的类路径中。

关于java - 从简单的 Java 客户端调用 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6623508/

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