-
大小: 367KB文件类型: .zip金币: 1下载: 0 次发布日期: 2021-06-15
- 语言: 数据库
- 标签: webservice
资源简介
服务发布,服务获取,解析等。含代码、详细开发文档,傻瓜式开发。webservice、arr、mysql
代码片段和文件信息
package client;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.databinding.utils.BeanUtil;
import org.apache.axis2.engine.DefaultobjectSupplier;
import org.apache.axis2.rpc.client.RPCServiceClient;
import javax.xml.namespace.QName;
import serviceServer.Student;
public class StudentSearchServlet extends HttpServlet {
public void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
String stuNum = request.getParameter(“num“);
try {
// 使用RPC方式调用WebService
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
// 指定调用WebService的URL
EndpointReference targetEPR = new EndpointReference(“http://localhost:8080/axis2/services/SCManager“);
options.setTo(targetEPR);
// 指定getGreeting方法的参数值
object[] opAddEntryArgs = new object[] {stuNum.trim()};
// 指定getGreeting方法返回值的数据类型的Class对象
Class[] classes = new Class[] {String.class};
// 指定要调用的getGreeting方法及WSDL文件的命名空间
QName opAddEntry = new QName(“http://ws.apache.org/axis2“ “getRelatedStudent“);
// 调用getGreeting方法并输出该方法的返回值
String[] results = ((String) serviceClient.invokeBlocking(opAddEntry opAddEntryArgs classes)[0]).split(““);
//System.out.println(results.length);
HttpSession session = request.getSession();
if(session.getAttribute(“stuNum“)!=null){session.removeAttribute(“stuNum“);}
if(session.getAttribute(“stuAge“)!=null){session.removeAttribute(“stuAge“);}
if(session.getAttribute(“stuName“)!=null){session.removeAttribute(“stuName“);}
if(session.getAttribute(“error“)!=null){session.removeAttribute(“error“);}
if(results.length==3){
session.setAttribute(“stuNum“ results[0]);
session.setAttribute(“stuName“ results[1]);
session.setAttribute(“stuAge“ results[2]);
}else if(!(stuNum.trim().equals(““))){
session.setAttribute(“error“ “无此人“);
}
else if(stuNum.trim().equals(““)){
}
RequestDispatcher dispatcher = request.getRequestDispatcher(“/index.jsp“);
dispatcher.forward(request response);
} catch (Exception e) {
e.printStackTrace();
}
}
public void doPost(HttpServletRequest request HttpServletResponse response)throws ServletException IOException {
doGet(requestresponse);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 436736 2015-05-13 11:04 webservice\webservice开发文档.doc
目录 0 2015-05-13 10:50 webservice\源码\
目录 0 2015-05-13 10:52 webservice\源码\client\
文件 1250 2015-05-13 10:47 webservice\源码\client\index.jsp
文件 3014 2015-05-13 10:38 webservice\源码\client\StudentSearchServlet.java
文件 726 2015-05-12 21:34 webservice\源码\client\web.xm
目录 0 2015-05-13 10:52 webservice\源码\webservice\
目录 0 2015-05-13 10:52 webservice\源码\webservice\arr包\
文件 2008 2015-05-12 23:49 webservice\源码\webservice\arr包\SCManager.aar
目录 0 2015-05-13 10:50 webservice\源码\webservice\me
文件 326 2015-05-12 22:51 webservice\源码\webservice\me
文件 971 2015-05-13 10:21 webservice\源码\webservice\StudentMgr.java
- 上一篇:数据库技术与应用课后实训答案
- 下一篇:运动会管理系统源码
评论
共有 条评论