当前位置 : 主页 > 网页制作 > Nodejs >

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

来源:互联网 收集:自由互联 发布时间:2021-06-24
接口中使用注解定义 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.WSDLDocumentationColl

接口中使用注解定义

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,邮箱:xxx@126.com",  
	                           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,邮箱:xxx@126.com</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>
网友评论