/**
* A simple demo service which generates "hello".
* @author Jeffrey Hsu
* @version 0.1, 2006-5-24
*/
public class HelloServiceImpl implements HelloService {
public String sayHelloTo(String name) {
return "Greetings, " + name + ", What can I do for you?";
}
public String sayHelloTo(Name name) {
return "Greetings, " + name + ", What can I do for you?";
}
}
if (serverURL == null) {
synchronized (this) {
if (serverURL == null) {
// Your rpcrouter url
String url = "http://localhost:8080/SoapDemo/servlet/rpcrouter";
try {
serverURL = new URL(url);
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}
}
}
}
final public static Object newInstance(String urn, Class[] interfaces) {
SoapProxy pi = new SoapProxy(urn);
return (pi.initialize(interfaces));
}
// Implementation of the InvocationHandler interface
final public Object invoke(Object proxy, Method m, Object[] args)
throws Throwable {
Call call = new Call();
call.setTargetObjectURI(urn);
call.setMethodName(m.getName());
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
java.util.Vector params = new java.util.Vector();
for (int i = 0; i < args.length; i++) {
if (isSimple(args[i]) || isSimpleArray(args[i])) {
params.add(new Parameter(PARAM_NAME + (i + 1),
args[i].getClass(), args[i], null));
} else if (isVector(args[i])) {
addMapping((java.util.Vector) args[i]);
params.add(new Parameter(PARAM_NAME + (i + 1),
args[i].getClass(), args[i], null));
}
else if (isArray(args[i])) {
if (smr == null) {
smr = new SOAPMappingRegistry();
}
if (beanSer == null) {
beanSer = new BeanSerializer();
}
private boolean isSimple(Object o) {
if (o instanceof Integer || o instanceof Double ||
o instanceof Boolean || o instanceof Byte ||
o instanceof Character || o instanceof Float ||
o instanceof String || o instanceof Short || o instanceof Long) {
return (true);
}
return (false);
}
private boolean isSimpleArray(Object o) {
if (o instanceof int[] || o instanceof boolean[] ||
o instanceof long[] || o instanceof float[] ||
o instanceof short[] || o instanceof byte[] ||
o instanceof java.lang.Integer[] ||
o instanceof java.lang.Double[] ||
o instanceof java.lang.Boolean[] ||
o instanceof java.lang.Byte[] ||
o instanceof java.lang.Float[] ||
o instanceof java.lang.String[] ||
o instanceof java.lang.Short[] ||
o instanceof java.lang.Long[]) {
return (true);
}
return (false);
}
private boolean isVector(Object o) {
if (o instanceof java.util.Vector) {
return (true);
}
return (false);
}
private boolean isArray(Object o) {
if (o instanceof Object[]) {
return (true);
}
return (false);
}
private void addMapping(java.util.Vector v) {
Object o = v.get(0);
if (o == null) {
return;
}
if (isSimple(o) || isSimpleArray(o)) {
// System.out.println("Vector contains simple elements only.");
} else if (isVector(o)) {
// System.out.println("Recursive Vector...");
addMapping((java.util.Vector) o);
} else {
if (smr == null) {
smr = new SOAPMappingRegistry();
}
if (beanSer == null) {
beanSer = new BeanSerializer();
}