hi,
   The first is programmed to serialize and deserialize a string.
        And the second is programmed to serialize and deserialize a javaBean.
        Now I paste my programs as followed:
//////////////////////////////////      
Client2.java

package hello;
import java.net.URL;
import java.util.Vector;
import org.apache.soap.SOAPException;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
import org.apache.soap.encoding.SOAPMappingRegistry;
import org.apache.soap.encoding.soapenc.BeanSerializer;
import org.apache.soap.util.xml.QName;

public class Client2
{
   public static void main(String[] args) throws Exception
   {
      if(args.length == 0)
      {
         System.err.println("Usage: java hello.Client [SOAP-router-URL] ");
         System.exit (1);
      }

      try
      {
         URL url = null;
         String name = null;
         if(args.length == 2)
         {
            url = new URL(args[0]);
            name = args[1];
         }
         else
         {
            url = new URL("http://localhost:8080/apache-soap/servlet/rpcrouter";);
            name = args[0];
         }

         // Build the call.
         Call call = new Call();
         call.setTargetObjectURI("urn:Hello");
         call.setMethodName("sayHelloTo");
         call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

         // Create the type mapping registry
         SOAPMappingRegistry smr = new SOAPMappingRegistry();
         BeanSerializer beanSer = new BeanSerializer();
         // Map the types.
         smr.mapTypes(Constants.NS_URI_SOAP_ENC,
             new QName("urn:Hello", "hello.Name"),hello.Name.class, beanSer, beanSer);
         // and tell the Call object to use it..
         call.setSOAPMappingRegistry(smr);

         // Set the Parameters
         Vector params = new Vector();
         Name theName = new Name();
         theName.setName(name);
         params.addElement(new Parameter("name", hello.Name.class, theName, null));
         call.setParams(params);

         // Invoke the call.
         Response resp = null;
         try
         {
            resp = call.invoke(url, "");
         }
         catch( SOAPException e )
         {
            System.err.println("Caught SOAPException (" + e.getFaultCode() + "): " + 
e.getMessage());
            System.exit(-1);
         }

         // Check the response.
         if( !resp.generatedFault() )
         {
            Parameter ret = resp.getReturnValue();
            Object value = ret.getValue();
            System.out.println(value);
         }
         else
         {
            Fault fault = resp.getFault();
            System.err.println("Generated fault: ");
            System.out.println ("  Fault Code   = " + fault.getFaultCode());
            System.out.println ("  Fault String = " + fault.getFaultString());
         }
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
   }
}
//////////////////////////////////
HelloServer.java

package hello;
public class HelloServer
{
  public String sayHelloTo(String name)
   {
      System.out.println("sayHelloTo(String name)");
      return "Hello " + name + ", How are you doing?";
   }

   public String sayHelloTo(Name theName)
   {
      System.out.println("sayHelloTo(Name theName)");
      return "Hello " + theName.getName() + ", How are you doing?";
   }

}
/////////////////////////////////////
the JavaBean named Name.java

package hello;
public class Name
{
   private String name;
   public String getName()
   {
      return name;
   }
   public void setName(String name)
   {
      this.name = name;
   }
}
////////////////////////////////////
ok.That's all.Now I run it as "java hello.Client2 
http://localhost:8080/apache-soap/servlet/rpcrouter amy".And there is a message as 
followed:
Generated fault:
  Fault Code   = SOAP-ENV:Client
  Fault String = Deployment error in SOAP service 'urn:Hello': class name 'hello.Name' 
could not be resolved: hello.Name

I think maybe there is something wrong when I deploy it.
Who knows?


thanks 



a puzzled girl 

amy

Reply via email to