【求助】关于xml-rpc的问题

06-06-23 ye730321
按照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>

请问这段代码是放在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)

猜你喜欢