【求助】關於xml-rpc的問題

ye730321發表於2006-06-23
按照ws-apache中xml-rpc的example,進行試驗,但是總是不能成功,不知道哪位使用過,說說成功的經驗吧
我寫的client程式碼如下:

package com.koook.xmlrpc.test;
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory;

public class Client {
	public int doClient() throws MalformedURLException, XmlRpcException{
		try{
			XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
		    config.setServerURL(new URL("http://127.0.0.1:8080/XmlRpcServlet"));
		    XmlRpcClient client = new XmlRpcClient();
		    client.setTransportFactory(new XmlRpcCommonsTransportFactory(client));
		    client.setConfig(config);
		    Object[] params = new Object[]{new Integer(2), new Integer(3)};
		    Integer result = (Integer) client.execute("Calculator.add", params);
		    int returnnum = result;
		    System.out.println("adadadaadasd"+result);
		    return returnnum;
		}finally{}
	}
}
<p class="indent">


請問這段程式碼是放在jsp裡面呼叫,還是建立一個class,然後透過jsp呼叫,我是透過後者的,但是出現如下錯誤

javax.servlet.ServletException: Failed to parse servers response: Expected methodResponse element, got html
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:61)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

相關文章