微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在CXF开发的WebService接口WSDL信息中添加注释

接口中使用注解定义

package edu.xxx.service;


import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import org.apache.cxf.annotations.WSDLDocumentation;
import org.apache.cxf.annotations.WSDLDocumentationCollection;

@WebService
@WSDLDocumentationCollection(  
	    {  
	        @WSDLDocumentation(value = "数据中心用户信息接口:为第三方子系统提供用户信息,访问此接口的客户端需要IP授权。作者:xxx,邮箱:[email protected]",placement = WSDLDocumentation.Placement.TOP) 
	    }  
	)
public interface IUserService {
	@WebMethod  
	@WSDLDocumentation( "返回JSON格式数据") 
	String getUserListForjson(@WebParam(name="pageNum") Integer pageNum,@WebParam(name="pageSize") Integer pageSize);
	
	@WebMethod
	@WSDLDocumentation( "返回XML格式数据")
	String getUserListForXml(@WebParam(name="pageNum") Integer pageNum,@WebParam(name="pageSize") Integer pageSize);
	
	@WebMethod
	@WSDLDocumentation( "返回已经封闭好数据对象")
	ResponSEObject getUserListForObject(@WebParam(name="pageNum") Integer pageNum,@WebParam(name="pageSize") Integer pageSize);
	
}
结果:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:deFinitions name="IUserServiceService" targetNamespace="http://service.xxx.edu/">
  <wsdl:documentation>数据中心用户信息接口:为第三方子系统提供用户信息,需要访问此插口的客户端需要IP授权。作者:xxx,邮箱:[email protected]</wsdl:documentation>
  <wsdl:types>
    <xs:schema elementFormDefault="unqualified" targetNamespace="http://service.xxx.edu/" version="1.0">
      <xs:element name="getUserListForjson" type="tns:getUserListForjson"/>
      <xs:element name="getUserListForjsonResponse" type="tns:getUserListForjsonResponse"/>
      <xs:element name="getUserListForObject" type="tns:getUserListForObject"/>
      <xs:element name="getUserListForObjectResponse" type="tns:getUserListForObjectResponse"/>
      <xs:element name="getUserListForXml" type="tns:getUserListForXml"/>
      <xs:element name="getUserListForXmlResponse" type="tns:getUserListForXmlResponse"/>
      <xs:complexType name="getUserListForXml">
        <xs:sequence>
          <xs:element minOccurs="0" name="pageNum" type="xs:int"/>
          <xs:element minOccurs="0" name="pageSize" type="xs:int"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="getUserListForXmlResponse">
        <xs:sequence>
          <xs:element minOccurs="0" name="return" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="getUserListForjson">
        <xs:sequence>
          <xs:element minOccurs="0" name="pageNum" type="xs:int"/>
          <xs:element minOccurs="0" name="pageSize" type="xs:int"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="getUserListForjsonResponse">
        <xs:sequence>
          <xs:element minOccurs="0" name="return" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="getUserListForObject">
        <xs:sequence>
          <xs:element minOccurs="0" name="pageNum" type="xs:int"/>
          <xs:element minOccurs="0" name="pageSize" type="xs:int"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="getUserListForObjectResponse">
        <xs:sequence>
          <xs:element minOccurs="0" name="return" type="tns:responSEObject"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="responSEObject">
        <xs:sequence>
          <xs:element minOccurs="0" name="availablePage" type="xs:int"/>
          <xs:element maxOccurs="unbounded" minOccurs="0" name="data" nillable="true" type="tns:user"/>
          <xs:element minOccurs="0" name="message" type="xs:string"/>
          <xs:element minOccurs="0" name="status" type="xs:string"/>
          <xs:element minOccurs="0" name="totalRecords" type="xs:int"/>
        </xs:sequence>
      </xs:complexType>
      <xs:complexType name="user">
        <xs:sequence>
          <xs:element minOccurs="0" name="userDept" type="xs:string"/>
          <xs:element minOccurs="0" name="userId" type="xs:string"/>
          <xs:element minOccurs="0" name="userIdentity" type="xs:string"/>
          <xs:element minOccurs="0" name="userName" type="xs:string"/>
          <xs:element minOccurs="0" name="userType" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="getUserListForObject">
    <wsdl:part element="tns:getUserListForObject" name="parameters"> </wsdl:part>
  </wsdl:message>
  <wsdl:message name="getUserListForjson">
    <wsdl:part element="tns:getUserListForjson" name="parameters"> </wsdl:part>
  </wsdl:message>
  <wsdl:message name="getUserListForObjectResponse">
    <wsdl:part element="tns:getUserListForObjectResponse" name="parameters"> </wsdl:part>
  </wsdl:message>
  <wsdl:message name="getUserListForjsonResponse">
    <wsdl:part element="tns:getUserListForjsonResponse" name="parameters"> </wsdl:part>
  </wsdl:message>
  <wsdl:message name="getUserListForXmlResponse">
    <wsdl:part element="tns:getUserListForXmlResponse" name="parameters"> </wsdl:part>
  </wsdl:message>
  <wsdl:message name="getUserListForXml">
    <wsdl:part element="tns:getUserListForXml" name="parameters"> </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="IUserService">
    <wsdl:operation name="getUserListForXml">
      <wsdl:documentation>返回XML格式数据</wsdl:documentation>
      <wsdl:input message="tns:getUserListForXml" name="getUserListForXml"> </wsdl:input>
      <wsdl:output message="tns:getUserListForXmlResponse" name="getUserListForXmlResponse"> </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getUserListForjson">
      <wsdl:documentation>返回JSON格式数据</wsdl:documentation>
      <wsdl:input message="tns:getUserListForjson" name="getUserListForjson"> </wsdl:input>
      <wsdl:output message="tns:getUserListForjsonResponse" name="getUserListForjsonResponse"> </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getUserListForObject">
      <wsdl:documentation>返回已经封闭好数据对象</wsdl:documentation>
      <wsdl:input message="tns:getUserListForObject" name="getUserListForObject"> </wsdl:input>
      <wsdl:output message="tns:getUserListForObjectResponse" name="getUserListForObjectResponse"> </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="IUserServiceServiceSoapBinding" type="tns:IUserService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getUserListForjson">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="getUserListForjson">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="getUserListForjsonResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getUserListForXml">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="getUserListForXml">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="getUserListForXmlResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getUserListForObject">
      <soap:operation soapAction="" style="document"/>
      <wsdl:input name="getUserListForObject">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="getUserListForObjectResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="IUserServiceService">
    <wsdl:port binding="tns:IUserServiceServiceSoapBinding" name="IUserServicePort">
      <soap:address location="http://localhost:8080/UserSAPI/service/user"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:deFinitions>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐