wsdl2java根据WSDL文件生成java文件

本文主要使用的是axis

使用命令如下:

java -cp D:\javalib\web\*; org.apache.axis.wsdl.WSDL2Java http://ip:port/serverurl?wsdl

D:\javalib\web 为axis的lib目录
执行完毕后会生成对应的文件。

调用方法:

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        //sendSystemMessage

        GImplServiceLocator service = new GImplServiceLocator();
        GSoapBindingStub serviceStub;
        try {
            serviceStub = (GSoapBindingStub) service.getGeneric();
            String test = serviceStub.sendSystemMessage(.......);
        } catch (ServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }

也可以采用这种方式调用:

    URL address = '''''';
    try
    {
      address = new URL(address);
    }
    catch (MalformedURLException e1)
    {
      e1.printStackTrace();
    }
    GImplService service = new GImplServiceLocator();
    GImpl generic = null;
    String v_k = "0";
    try
    {
      generic = service.getGeneric(address);
    }
    catch (ServiceException e)
    {
      e.printStackTrace();
    }
    if (generic != null) {
      try
      {
        v_k = generic.sendSystemMessage(。。。。。);
      }
      catch (RemoteException e)
      {
        e.printStackTrace();
      }
    }

你可能感兴趣的:(wsdl2java根据WSDL文件生成java文件)