wsimport的使用

目前生成webservice的三种方式:零配置,services.xml的配置方式,jax-ws的方式。

 

jdk6提供了新的生成stub类的方式,wsimport。

D:\Users\Meng>wsimport -keep http://localhost:8080/axis2/services/FirstService.F
irstPort?wsdl

 

把生成的java文件拷贝到项目即可调用。

使用Qname可以配置url。

package client;

import service.First;
import service.FirstService;

public class WSImportTest {

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

        FirstService fs=new FirstService();
        First first=fs.getFirstPort();
        System.out.println(first.getMsg("eric"));
        
    }

}

 使用wsimport时会自动生成相应的接口,如果需要自己指定,可以在编写webservice的时候自己指定。

需要注意的事项:

1,实现接口是webservice注解必须指定endpointinterface属性,并且是全局名称。

2,webmethod注解指定在接口中,类中不能在指定。

 

 

还有两个比较常用的属性,serviceName,portName来指定service名字和port名字。

 

posted @ 2014-10-07 22:46  menglgcn  阅读(148)  评论(0)    收藏  举报