Java-WS Eclipse忽略接口自定义注释

时间:2013-12-20 22:44:58

标签: java eclipse web-services wsdl

我一直在尝试使用Eclipse(用于Web开发人员的Eclipse Java EE IDE,Kepler Service Release 1)构建Jave Web服务。我编写了代码,并使用Eclipse为它生成一个Web服务(它也会为它创建WSDL文件)。我注意到结果Web服务似乎忽略了所有接口注释(@WebMethod,@ WebResult等等)。使用wsgen,所有注释似乎都得到了尊重。

这是设计还是我在这里做错了什么?

以下是服务的源代码,Eclipse生成的WSDL如下:

package org.itemKeyGenerator;

import java.sql.SQLException;
import java.util.NoSuchElementException;

import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;

import org.itemKeyGenerator.beans.DocumentKey;
import org.itemKeyGenerator.beans.ElementKey;
import org.itemKeyGenerator.beans.GroupKey;

@WebService (serviceName = "itemKeyGeneratorService", portName = "itemKeyGenerator")
public class ItemKeyGeneratorService {

    private static DatabaseAdapter adapter = new DatabaseAdapter();

    public ItemKeyGeneratorService() {}

    @WebMethod(operationName = "generate_document_key")
    @WebResult(name = "key")
    public DocumentKey generateDocumentKey() throws SQLException, NoSuchElementException {
        return adapter.generateAndGetDocumentKey();
    }

    @WebMethod(operationName = "generate_group_key")
    public @WebResult(name = "key")GroupKey generateGroupKey(
            DocumentKey k) throws SQLException, NoSuchElementException {
        return adapter.generateAndGetInvoiceElementGroupKey(k);
    }

    @WebMethod(operationName = "generate_element_key")
    public @WebResult(name = "key")ElementKey generateElementKey(
            GroupKey k) throws SQLException, NoSuchElementException {
        return adapter.generateAndGetInvoiceElementDetailKey(k);
    }

}

Eclipse生成了WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://itemKeyGenerator.org" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://itemKeyGenerator.org" xmlns:intf="http://itemKeyGenerator.org" xmlns:tns1="http://beans.itemKeyGenerator.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://itemKeyGenerator.org" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://beans.itemKeyGenerator.org"/>
   <element name="generateDocumentKey">
    <complexType/>
   </element>
   <element name="generateDocumentKeyResponse">
    <complexType>
     <sequence>
      <element name="generateDocumentKeyReturn" type="tns1:DocumentKey"/>
     </sequence>
    </complexType>
   </element>
   <element name="generateInvoiceElementGroupKey">
    <complexType>
     <sequence>
      <element name="k" type="tns1:DocumentKey"/>
     </sequence>
    </complexType>
   </element>
   <element name="generateInvoiceElementGroupKeyResponse">
    <complexType>
     <sequence>
      <element name="generateInvoiceElementGroupKeyReturn" type="tns1:InvoiceElementGroupKey"/>
     </sequence>
    </complexType>
   </element>
   <element name="generateInvoiceElementDetailKey">
    <complexType>
     <sequence>
      <element name="k" type="tns1:InvoiceElementGroupKey"/>
     </sequence>
    </complexType>
   </element>
   <element name="generateInvoiceElementDetailKeyResponse">
    <complexType>
     <sequence>
      <element name="generateInvoiceElementDetailKeyReturn" type="tns1:InvoiceElementDetailKey"/>
     </sequence>
    </complexType>
   </element>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://beans.itemKeyGenerator.org" xmlns="http://www.w3.org/2001/XMLSchema">
   <complexType name="DocumentKey">
    <sequence>
     <element name="documentKey" type="xsd:long"/>
    </sequence>
   </complexType>
   <complexType name="InvoiceElementGroupKey">
    <sequence>
     <element name="documentKey" nillable="true" type="tns1:DocumentKey"/>
     <element name="invoiceElementGroupKey" type="xsd:long"/>
    </sequence>
   </complexType>
   <complexType name="InvoiceElementDetailKey">
    <sequence>
     <element name="invoiceElementDetailKey" type="xsd:long"/>
     <element name="invoiceElementGroupKey" nillable="true" type="tns1:InvoiceElementGroupKey"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>

   <wsdl:message name="generateInvoiceElementDetailKeyRequest">

      <wsdl:part element="impl:generateInvoiceElementDetailKey" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="generateInvoiceElementDetailKeyResponse">

      <wsdl:part element="impl:generateInvoiceElementDetailKeyResponse" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="generateDocumentKeyResponse">

      <wsdl:part element="impl:generateDocumentKeyResponse" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="generateInvoiceElementGroupKeyRequest">

      <wsdl:part element="impl:generateInvoiceElementGroupKey" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="generateDocumentKeyRequest">

      <wsdl:part element="impl:generateDocumentKey" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:message name="generateInvoiceElementGroupKeyResponse">

      <wsdl:part element="impl:generateInvoiceElementGroupKeyResponse" name="parameters">

      </wsdl:part>

   </wsdl:message>

   <wsdl:portType name="ItemKeyGeneratorService">

      <wsdl:operation name="generateDocumentKey">

         <wsdl:input message="impl:generateDocumentKeyRequest" name="generateDocumentKeyRequest">

       </wsdl:input>

         <wsdl:output message="impl:generateDocumentKeyResponse" name="generateDocumentKeyResponse">

       </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="generateInvoiceElementGroupKey">

         <wsdl:input message="impl:generateInvoiceElementGroupKeyRequest" name="generateInvoiceElementGroupKeyRequest">

       </wsdl:input>

         <wsdl:output message="impl:generateInvoiceElementGroupKeyResponse" name="generateInvoiceElementGroupKeyResponse">

       </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="generateInvoiceElementDetailKey">

         <wsdl:input message="impl:generateInvoiceElementDetailKeyRequest" name="generateInvoiceElementDetailKeyRequest">

       </wsdl:input>

         <wsdl:output message="impl:generateInvoiceElementDetailKeyResponse" name="generateInvoiceElementDetailKeyResponse">

       </wsdl:output>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="ItemKeyGeneratorServiceSoapBinding" type="impl:ItemKeyGeneratorService">

      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="generateDocumentKey">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="generateDocumentKeyRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="generateDocumentKeyResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="generateInvoiceElementGroupKey">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="generateInvoiceElementGroupKeyRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="generateInvoiceElementGroupKeyResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

      <wsdl:operation name="generateInvoiceElementDetailKey">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="generateInvoiceElementDetailKeyRequest">

            <wsdlsoap:body use="literal"/>

         </wsdl:input>

         <wsdl:output name="generateInvoiceElementDetailKeyResponse">

            <wsdlsoap:body use="literal"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>

   <wsdl:service name="ItemKeyGeneratorServiceService">

      <wsdl:port binding="impl:ItemKeyGeneratorServiceSoapBinding" name="ItemKeyGeneratorService">

         <wsdlsoap:address location="http://localhost:8080/KeyGeneratorService/services/ItemKeyGeneratorService"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>

过去一周我一直在玩它,寻找答案,并试图找出答案。我对此事的任何帮助表示感谢。

非常感谢!

  • 劳伦斯

0 个答案:

没有答案
相关问题