eui怎么让动作条变大:jsp中调用webservice 代码
来源:百度文库 编辑:中财网 时间:2024/04/28 04:37:25
public String sayHello(){
return "Hello world!";
}
调用方法如下:
////////////////////////////此方法调用webservice的方法,返回值/////////////////////////////////////
public String getString()
{
String ret = null;
try
{
String endpoint =
"http://localhost:8080/LSA/services/test";
Service service = new Service();
Call call = null;
call = (Call) service.createCall();
call.setOperationName(new QName(
"http://localhost:8080/LSA/services/test",
"sayHello"));
call.setTargetEndpointAddress(new java.net.URL(endpoint));
ret=(String)call.invoke(new Object[]{});
}catch(Exception e)
{
e.printStackTrace();
}
return ret;
}
/////////////////////////////////////END//////////////////////////////////////////////
调用带参数的webservice
public void getString()
{
String ret = null;
try
{
String endpoint =
"http://localhost:8083/Receive/services/AddUser";
Service service = new Service();
Call call = null;
call = (Call) service.createCall();
call.setOperationName(new QName(
"http://localhost:8083/Receive/services/AddUser",
"AddUser"));
call.addParameter("BH",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
call.addParameter("MM",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
//call.invoke("1");
call.setTargetEndpointAddress(new java.net.URL(endpoint));
ret=(String)call.invoke(new Object[]{"2","2"});
}catch(Exception e)
{
e.printStackTrace();
}
//return ret;
}