@WebService @WebMethod 详解


形象图解

首先AB均需要@WebService
如果

@WebService(endpointInterface="package.B")
public class A implements/extends B

那么有以下三种情况
1. A的自有方法(不能被发现)
2. A的重写方法(被发现且使用该方法)
3. A的继承方法(被发现且使用父类该方法)

          A          B
          |
--->----<-|          |->
--->----<------------|->

@WebService

Marks a Java class as implementing a Web Service, or a Java interface as defining a Web Service interface.

name

wsdl:portType

提供方法的类的别名

默认是该类名

HelloServiceImpl serv = service.getPort(HelloServiceImpl.class);

targetNamespace

在A使用(AB模式)wsdl:service
在B使用(AB模式)wsdl:portType
在A使用(A  模式)wsdl:service 、wsdl:portType

使用 endpointInterface="package.B" 开启AB模式

命名空间未指定的使用默认命名空间

命名空间影响client生成代码时的package

serviceName

wsdl:service 

QName qname = new QName("http://impl.service.zno.cn/","HelloService1");

默认serviceName 是 默认name+Service

指定name不能改变serviceName ,依旧是默认name+Service

portName

wsdl:port

不同于name ,它只影响xml ,不会影响client生成代码

wsdlLocation

The location of a pre-defined WSDL describing the service.

endpointInterface

定义服务的抽象web服务,暴露用 

@WebMethod

operationName

wsdl:operation

方法伪装

action

soap action 

exclude

方法排除用

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM