|
import java.net.MalformedURLException;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
You use this to see.
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;
public class AxisWSClient
{
private String endpoint;
private String qName;
private String operationName;
public AxisWSClient (String endpoint, String qName, String operationName)
{
this.endpoint = endpoint;
this.qName = qName;
this.operationName = operationName;
}
public Object getRemoteResult (Object [] inParam, Class outClazz) throws RemoteException
{
String endpoint = this.endpoint;
String qName = this.qName;
String operationName = this.operationName;
Call call = null;
//System.out.println("11111111111111 ");
Object [] o = new Object [] {};
try
{
Service service = new Service ();
call = (Call) service.createCall ();
call.setTargetEndpointAddress (new java.net.URL (endpoint));
call.setOperationName (new QName (qName, operationName));
if (inParam! = null)
o = inParam;
if (outClazz! = null)
{
String className = outClazz.getName ();
int i = className.lastIndexOf (".") + 1;
className = className.substring (i, className.length ());
Ranch
QName qn = new QName ("urn:" + className, className);
call.registerTypeMapping (outClazz, qn, new BeanSerializerFactory (outClazz, qn),
new BeanDeserializerFactory (outClazz, qn));
}
}
catch (MalformedURLException e)
{
e.printStackTrace ();
}
catch (Exception e)
{
e.printStackTrace ();
}
return call.invoke (o);
}
public Object getRemoteResult (Class inParamClazz, Class outClazz)
{
return null;
}
public Object getRemoteResult (Class inParamClazz)
{
return null;
}
public static void main (String args [])
{
/ *
* test string function
* /
/ * AxisWSClient kc = new AxisWSClient ("http://127.0.0.1:7001/WebRoot/services/TestWS",
"services.blackjack.ftyd.com", "testString");
Object [] o = new Object []
{new String ("shinhua")};
try
{
String sr = (String) kc.getRemoteResult (o, null);
System.out.println (sr);
}
catch (RemoteException e)
{
e.printStackTrace ();
} * /
Ranch
Ranch
}
} |
|