在xfire中url传参数
在xfire中调用方法通过方法传递参数
public interface Isayhello
{
public String example(String message);
public Student saveStudent(Student s);
}
public class ServiceClassTest {
public void Test(){
ObjectServiceFactory o=new ObjectServiceFactory();
Service ss=o.create(Isayhello.class);
XFireProxyFactory xf=new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String url="http://localhost:8080/ss/services/sayhello";
try{
Isayhello a=(Isayhello)xf.create(ss, url);
System.out.println(a.example("ssss"));
}catch(Exception ex){
System.out.println(ex.getMessage());
}
}
public Object Test(String className,String url){
ObjectServiceFactory o=new ObjectServiceFactory();
Service ss=null;
try {
ss = o.create(Class.forName(className));
} catch (
ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
XFireProxyFactory xf=new XFireProxyFactory(XFireFactory.newInstance().getXFire());
Object a=null;
try{
a=xf.create(ss, url);
}catch(Exception ex){
}
return a;
}
public static void main(String args[]){
ServiceClassTest t=new ServiceClassTest();
// t.Test();
String url="http://localhost:8080/ss/services/sayhello";
Isayhello is=(Isayhello) t.Test("cicro.Isayhello", url);
String message=is.example("sss");
System.out.println(message);
Student s=new Student();
s.setAge("12");
s=is.saveStudent(s);
System.out.print(s);
// ServiceClassTest t=new ServiceClassTest();
//// t.Test();
// String url="http://localhost:8080/eya/services/TraceInsu";
// ITraceInsuService is=(ITraceInsuService) t.Test("com.service.ITraceInsuService", url);
// String message=is.Face("E0102","aa");
// System.out.println(message);
}
这样调用
但是如果url中传递参数,参数值该怎么获取,请给位高手指点一二
------解决方案--------------------t.Test(String args2,String args2);
然后将参数加入到url里面
------解决方案--------------------String url="http://localhost:8080/eya/services/TraceInsu";
url += "?a=1&b=2"
------解决方案--------------------request就可以获得啊
------解决方案--------------------webservice 不能在地址中加参数
webservice 就是远程调用方法和普通的web不一样