ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vinod Kumar <vi...@sofent.com>
Subject reg: org.apache.xmlrpc.client.XmlRpcClientException: Failed to obtain input stream from server
Date Tue, 27 Jun 2006 10:30:56 GMT
Hi all,

When i run the Calculator application, I got the following errors.

org.apache.xmlrpc.client.XmlRpcClientException: Failed to obtain input 
stream from server

I have enclosed my all applications. Please advice me.

XmlRpcServlet.properties
---------------------------
Calculator=org.apache.xmlrpc.demo.Calculator

Handler application Calculator.java
------------------------------------
package org.apache.xmlrpc.demo;

/**
* @author Vino
*
*/
public class Calculator {
   //For adding two numbers
   public int add(int first,int second){
       return (first+second);
   }
     //For substracting two  numbers
   public int sub(int first,int second){
       return (first+second);
   }
  }

Web.xml file
----------
<web-app>
<servlet>
       <servlet-name>XmlRpcServlet</servlet-name>
       
<servlet-class>org.apache.xmlrpc.webserver.XmlRpcServlet</servlet-class>
       <init-param>
         <param-name>enabledForExtensions</param-name>
         <param-value>true</param-value>
         <description>
           Sets, whether the servlet supports vendor extensions for 
XML-RPC.
         </description>
       </init-param>
   </servlet>
   <servlet-mapping>
       <servlet-name>XmlRpcServlet</servlet-name>
       <url-pattern>/xmlrpc</url-pattern>
   </servlet-mapping>


<servlet>
       <servlet-name>ClientAppln</servlet-name>
       
<servlet-class>org.apache.xmlrpc.clientappln.ClientAppln</servlet-class>
   </servlet>

   <servlet-mapping>
       <servlet-name>ClientAppln</servlet-name>
       <url-pattern>/client</url-pattern>
   </servlet-mapping>

</web-app>


Client application
-------------------

package org.apache.xmlrpc.clientappln;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory;
import org.apache.xmlrpc.server.XmlRpcServer;




/**
* @author Vino
*
*/
public class ClientAppln extends HttpServlet {
   public void service(HttpServletRequest request,HttpServletResponse 
response)throws ServletException,IOException{
       response.setContentType("text/html");
       PrintWriter out=response.getWriter();
                   try{
                               XmlRpcClientConfigImpl config=new 
XmlRpcClientConfigImpl();
                              config.setServerURL(new 
URL("http://localhost:9090/xmlrpc"));
                    XmlRpcClient client=new XmlRpcClient();
           //client.setTransportFactory(new 
XmlRpcCommonsTransportFactory(new XmlRpcClient()));
                     client.setConfig(config);
                   Object[] params=new Object[]{new Integer(5),new 
Integer(3)};
                              // out.println("SUM is : 
"+client.execute("Calculator.add",params));
           Integer result=(Integer)client.execute("Calculator.add",params);
                   out.println("SUM is : "+result);
                          }
       catch(XmlRpcException xmlrpcExcep){
           out.println("Exception in ClientAppln : "+xmlrpcExcep);
       }
               }
}


Regds

Vinod.




---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-user-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-user-help@ws.apache.org


Mime
View raw message