use*_*944 39 java xml soap web-services
我在调用Web服务中存在的方法时遇到问题.wsdl是使用AXIS创建的.
当我尝试使用我的java代码调用它时,我从服务响应中获取空值.
我收到了在我的控制台中打印的警告消息:
无法找到所需的类(javax.activation.DataHandler和javax.mail.internet.MimeMultipart).附件支持已禁用.
在尝试解决此问题时,我在工作区构建路径中添加了activation.jar和mail.jar,重新启动了服务器.
编辑:
右键单击WSDL ==>生成CLient
然后我得到了一个代理类,使用它我写这个来调用服务方法:
public class CallingWebService1 {
public static void main(String[] args) throws Exception {
WebService1Proxy proxy1 = new WebService1Proxy();
proxy1.setEndpoint("http://localhost:8045/WebService1/services/WebService1");
EmployeeDetails details = proxy1.getDetails();
System.out.println("Employee Id: " + details.getEmpId());
System.out.println("Employee Name: " + details.getEmpName());
System.out.println("Dept Id: " + details.getDeptId());
System.out.println("Dept Name" + details.getDeptName());
System.out.println("Age: " + details.getAge());
}
Run Code Online (Sandbox Code Playgroud)
但问题仍然存在:(
更多信息:
getDetails()方法正在执行数据库操作,从Oracle DB中获取一些记录.为了执行DB操作,使用class12.jar.它与我正在做的方式调用服务方法有什么关系吗?
Apo*_*dis 42
要修复javax.activation.DataHandler问题,必须在类路径中添加JavaBeans Activation Framework activation.jar.
要修复javax.mail.internet.mimeMultipart问题,必须在类路径中添加Java Mail API mail.jar.
控制台中打印的警告消息显示上述jar不在类路径中.
小智 7
不幸的是,wsdl 仍在使用:( 您可以通过添加下面的依赖项来解决此警告。
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
86632 次 |
最近记录: |