从jsp调用Webservices [英] calling Webservices from jsp
问题描述
我已成功创建了wsdl。它的URL是http://:/ aebis / HelpdeskWebserviceImpl?wsdl。
现在我想使用这个url来调用jsp中的函数。我使用Jboss作为服务器。
请提供建议,如果有人可以提供帮助。
先谢谢。
I have created the wsdl successfully .Its url is "http://:/aebis/HelpdeskWebserviceImpl?wsdl". Now I want to use this url to call the function in jsp.I am using Jboss as server. Please suggest if any one can help. Thanks in advance.
推荐答案
这是一个使用eclipse的5分钟示例
Here is a 5-minute example using eclipse
我将使用此WSDL演示
I am gonna use this WSDL to demonstrate
http://www.webservicex.net/ConvertAcceleration.asmx?WSDL
为JSP创建动态java项目
Create a dynamic java project for your JSPs
创建你的JSP和一些后端java类
Create your JSP and some backend java class
你的JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<%= new myweb.MyClass().getResult() %>
</body>
</html>
和
package myweb;
public class MyClass {
public String getResult(){
return null;
}
public static void main(String[] args) {
MyClass c = new MyClass();
System.out.println(c.getResult());
}
}
现在创建WS客户端。点击/选择项目
Now create the WS client. Click on/select the project
右键单击并从给定的WSDL创建新的Web服务客户端
right click and create a new Web Service Client from the given WSDL
更改MyClass以调用Web服务(您可以先使用类main测试
Change MyClass to call the web service (you can test first using the class main too)
package myweb;
import java.rmi.RemoteException;
import NET.webserviceX.www.AccelerationUnitSoap;
import NET.webserviceX.www.AccelerationUnitSoapProxy;
import NET.webserviceX.www.Accelerations;
public class MyClass {
public String getResult() throws RemoteException {
AccelerationUnitSoap a = new AccelerationUnitSoapProxy();
Accelerations x = Accelerations.decimeterPersquaresecond;
Accelerations y = Accelerations.centimeterPersquaresecond;
Object z = a.changeAccelerationUnit(1, x, y);
return z.toString();
}
public static void main(String[] args) throws RemoteException {
MyClass c = new MyClass();
System.out.println(c.getResult());
}
}
添加网页应用程序到您的服务器(如果有的话。如果没有,请创建一个新服务器)
Add the web app to your server (if there's one. If there isn't, create a new server)
清除服务器(强制刷新应用程序)并启动它
Clear the server (forcing it to refresh the app) and start it
这就是。
这篇关于从jsp调用Webservices的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!