Posted By:
mahesh_jangir
Posted On:
Wednesday, January 11, 2006 05:10 AM
hi, i am using tomcat 4.1, jdk 1.4 and soap 2.3.1...i have set classpath all required jar files (mail.jar,activation.jar,xerces.jar,soap.jar) and deploy service on server successfully... Service program--- /** Simple test of String and String[] parameters and return values */ public class HelloService1 { /** Says hello to one person */ public String helloString(String name) { return "Hello, " + name; } /** Says hello to many people */ public String[] helloStringArray(String[] names) { String[] ret = new String[names.length]; for (int i
More>>
hi,
i am using tomcat 4.1, jdk 1.4 and soap 2.3.1...i
have set classpath all required jar files
(mail.jar,activation.jar,xerces.jar,soap.jar) and deploy
service on server successfully...
Service program---
/** Simple test of String and String[] parameters and return values */
public class HelloService1
{
/** Says hello to one person */
public String helloString(String name)
{
return "Hello, " + name;
}
/** Says hello to many people */
public String[] helloStringArray(String[] names)
{
String[] ret = new String[names.length];
for (int i = 0; i
< names.length; i++)
ret[i] = "Hello, " + names[i];
return ret;
}
}
Client program---
import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import org.apache.soap.encoding.*;
/** Simple test of String and String[] parameters and return values */
public class HelloClient1
{
/** Gets the type of a class as a string */
private static String getType(Class c)
{
if (!c.isArray())
return c.getName();
return "array of " + getType(c.getComponentType());
}
/** Gets the value of an object as a string */
private static String getValue(Object o)
{
Class c = o.getClass();
if (!c.isArray())
return "'" + o.toString() + "'";
String ret = null;
Object[] oa = (Object[]) o;
for (int i = 0; i
< oa.length; i++) {
if (ret == null)
ret = "[" + getValue(oa[i]);
else
ret = ret + ", " + getValue(oa[i]);
}
return ret + "]";
}
/** Makes a SOAP call */
private static void makeCall(String targetURI,
String methodName,
String encodingStyleURI,
SOAPMappingRegistry smr,
Vector parameters,
String endpointURL) throws Exception {
Call call = new Call();
call.setTargetObjectURI(targetURI);
call.setMethodName(methodName);
call.setEncodingStyleURI(encodingStyleURI);
if (smr != null)
call.setSOAPMappingRegistry(smr);
call.setParams(parameters);
System.out.print("Call to method '" +
methodName +
"' of object '" +
targetURI + "' ");
Response resp = call.invoke(new URL(endpointURL),
targetURI);
// System.out.println(resp);
if (resp.generatedFault())
{
Fault fault = resp.getFault();
System.out.println("faulted:");
System.out.println(" Code = " + fault.getFaultCode());
System.out.println(" String = " + fault.getFaultString());
}
else
{
Parameter result = resp.getReturnValue();
Object value = result.getValue();
System.out.println("returned:");
System.out.println(" Type = " + getType(value.getClass()));
System.out.println(" Value = " + getValue(value));
}
}
/** Tests a service using String and String[] parameters and return values */
public static void main(String[] args) throws Exception
{
if (args.length
< 2)
{
System.err.println("Usage: java HelloClient1 SOAP-router-URL name [name ...]");
System.exit(1);
}
String targetURI = "urn:hello1";
String methodName = "helloString";
String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
Vector params = new Vector();
params.addElement(new Parameter("name", String.class, args[1], null));
String endpointURL = args[0];
// System.out.println(params);
// System.out.println(endpointURL);
makeCall(targetURI, methodName, encodingStyleURI, null, params, endpointURL);
methodName = "helloStringArray";
String[] names = new String[args.length - 1];
for (int i = 0; i
< args.length - 1; i++)
{
names[i] = args[i + 1];
// System.out.println(names[i]);
}
params = new Vector();
params.addElement(new Parameter("names", names.getClass(), names, null));
makeCall(targetURI, methodName, encodingStyleURI, null, params, endpointURL);
}
}
when i run client program then i recieved an error.. Error is......
Call to method 'helloString' of object 'urn:hello1' Exception in thread "main" [
SOAPException: faultCode=SOAP-ENV:Client; msg=No Deserializer found to deseriali
ze a ':return' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.
; targetException=java.lang.IllegalArgumentException: No Deserializer found to d
eserialize a ':return' using encoding style 'http://schemas.xmlsoap.org/soap/enc
oding/'.]
at org.apache.soap.rpc.Call.invoke(Call.java:244)
at HelloClient1.makeCall(HelloClient1.java:55)
at HelloClient1.main(HelloClient1.java:92)
please give me reasion of this exception
thanks and regards
mahesh
<<Less