我最近也在做论文,web services方面的,我的客户端调用方法测试过可以用的,看是否对你有帮助
package client;import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;import javax.xml.rpc.ServiceException;import _1._0._0._127.student.services.StudentManager.StudentManagerServiceLocator;
import _1._0._0._127.student.services.StudentManager.StudentManager;public class ClientTest { public static void main(String[] args) {
StudentManagerServiceLocator service = new StudentManagerServiceLocator();

try {
StudentManager client   =   service.getStudentManager(new URL("http://127.0.0.1:8080/student/services/StudentManager"));

client.addStudentInfo();
} catch (ServiceException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}   
}
}

解决方案 »

  1.   

    import _1._0._0._127.student.services.StudentManager.StudentManagerServiceLocator; 
    如果WebService是存在互联网上,怎么能用这个方法引用?
      

  2.   

    建议你看看STUB
    public class Db2Client {
        public static void main(String [] args) throws Exception
           {
              ArrayList result = null;     //ArrayList初始化
              String QueryTerm = “select *  from table”; //查询语句
              Service service = new Service();    
              Call call = (Call) service.createCall();
              QName qn = new QName(“urn:DB2STHD_HWService”,“Db2_STHD_HW”);   //注册命名空间
              call.registerTypeMapping(Db2_STHD_HW.class,qn,
                   new BeanSerializerFactory(Db2_STHD_HW.class, qn),
                   new BeanDeserializerFactory(Db2_STHD_HW.class, qn));        //自定义对象的序列化/反序列化   
              try{
                     call.setTargetEndpointAddress(new URL(“http://localhost:8080/axis/services/DB2STHD_HWService”));          //服务地址(wsdl描述地址)
                     call.setOperationName(new QName(“DB2STHD_HWService”,“getDB2Data”)); //调用服务函数
                     call.addParameter(“data”, qn, Db2_STHD_HW.class, ParameterMode.IN);    //参数类型说明
                     call.setReturnClass(ArrayList.class);                                                         //返回类型说明
                     result = (ArrayList) call.invoke(new Object[]{ QueryTerm});                     //得到返回的结果
                     for(int i = 0; i < result.size(); i++){                                                             //对返回结果进行解析
                          Db2_STHD_HW sthw = (Db2_STHD_HW)result.get(i);                    //取得结果集中每一节点
                           System.out.println(sthw.getSTCD() +“ ”+sthw.getSTNM() +“ “         //的数据库的数据
                                      +sthw.getSECTION() + " " + sthw.getSECTION_ID() + " "
                                      + sthw.getSORT() + " " + sthw.getTYPE());
                            }
                     }catch(Exception e) {
                      System.out.println( "Error : " + e.toString());
                        }
                      }
                  }
    //------------------------------------------------------------------------------
    其中有些方法是本人项目中的程序,你可以将其去掉,以上供你参考。
    你也可以看看“STUB”方面,可以根据对方的服务写个客户端,只需要服务地址就可以调用服务。