web服务涉及到的注解有:@WebService @WebMethod @Oneway @WebParam @WebResult @HandlerChain 结合实际操作案例 这里先介绍前两个,@WebService @WebMethod, @WebService @WebMethod 参照 webservice中常用注解--------------------@WebParam @WebResult
@WebService
该注解用于对接口,类进行注解,表示要发布的web服务
-
serviceName:发布的web服务名称;缺省值为java类的名称+Service(字符串) //如java类名称为SayWeb ,wsdl文档中 serviceName默认情况
<service name="SayWebService"> -
name:此属性的值包含XML Web Service的名称,对应wsdl文档中portType 的名称。 缺省值为 Java 类或接口的非限定名称。(字符串) //wsdl文档中 portType默认情况
<portType name="SayWeb"> -
portName:对应wsdl文档中portName,缺省值为 +Port //wsdl文档中 portName 默认情况 <port name="SayWebPort" binding="tns:SayWebPortBinding">
<soap:address location="http://localhost:9001/service/sayweb"/>
</port> -
targetNamespace:指定你想要的名称空间,认是使用接口实现类的包名的反缀 //wsdl文档中targetNamespace默认情况
targetNamespace="http://say_service/",在<definitions>标签中 - wsdlLocation:指定用于定义 Web Service 的 WSDL 文档的 Web 地址。默认情况是发布地址+?wsdl
@WebMethod
该注解用于用@WebService注解的类或接口的方法上,表示要发布的方法
-
soperationName:指定与此方法相匹配的wsdl:operation 的名称。缺省值为 Java 方法的名称。(字符串) //wsdl文档中soperationName默认情况,如方法为sayHello
<operation name="sayHello"></operation> 如果在sayHello方法上加注解@WebMethod(operationName="Hello"
<operation name="Hello"></operation>,客户端调用时,sayHello方法是不存在的,方法为Hello -
exclude:指定是否从 Web Service 中排除某一方法。缺省值为 false。(布尔值) @WebMethod(exclude=true)
public int sayInt(int i){
return ++i;
} //该方法不会发布