⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 execute.jsp

📁 精通Java核心技术源代码
💻 JSP
字号:
<%@ page language="java" import="java.util.Vector" %>
<%@ page import="java.net.MalformedURLException, java.net.URL" %>
<%@ page import="java.util.Vector" %>
<%@ page import="org.apache.soap.SOAPException, 
		org.apache.soap.Constants" %>
<%@ page import="org.apache.soap.rpc.Call, org.apache.soap.rpc.Response, 
		org.apache.soap.rpc.Parameter" %>
<%@ page import="org.apache.soap.transport.http.SOAPHTTPConnection" %>
<%@ page import="org.apache.soap.Fault" %>

<HTML>
<BODY bgcolor="Teal">
<br/>
<p align="center">
<font color="whitesmoke">
<% 
	boolean isParameter = false ;
	SOAPHTTPConnection soapTransport = new SOAPHTTPConnection();

	// Address of the remote server. 
	// Normally this should be dynamically passed and detected.
	// We have hard coded it only for demonstration.
	URL url = new URL ("http://localhost:8080/soap/servlet/rpcrouter");

	// Build the call.
	Call call = new Call ();
	call.setTargetObjectURI ("urn:BookService");
	call.setSOAPTransport (soapTransport);
	call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

	// We'll detect which method user selected
	// and give a call accordingly.
	// We'll pass parameters if present.

	if (request.getParameter("parameter")!=null)
	isParameter = true;

	if (request.getParameter("index").equals("0")) 
	{
		call.setMethodName("getPrice");
		Vector params = new Vector();
		String message = new String (request.getParameter("parameter"));
		params.addElement (new Parameter("message", String.class,message , null));
		call.setParams(params);
	}
	else
		call.setMethodName("getBookList");

	Response resp = call.invoke ( url,"");
	out.println("<p align=left><font size=\"4\" face=\"Arial\" color=\"white\">	Response of [ "+call.getMethodName()+" ]</font><hr/>");
	
	// Check the response.
	if (resp.generatedFault ()) {
		Fault fault = resp.getFault ();
		out.println("<b>Fault is:</b>"+ fault.getFaultCode ()
		+" ["+fault.getFaultString ()+"]");

	} else {
		Parameter result = resp.getReturnValue ();
		out.println("<b>Response is: </b>"+ result.getValue ()+"");
	}
%>
<font>
</p>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -