eclipse 无法从 WSDL 生成存根/java 框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6839414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:42:51  来源:igfitidea点击:

Not able to generate the stubs/java skeletons from the WSDL

javaeclipseweb-serviceswsdlwsdl2java

提问by java_enthu

I have written a WSDL to generate the Stubs and skeleton but my skeletons are not getting generated in the eclipse. I am using Helios version of Eclipse.
Can any one tell what is the issue with WSDL?

我已经编写了一个 WSDL 来生成存根和骨架,但是我的骨架没有在 Eclipse 中生成。我正在使用 Eclipse 的 Helios 版本。
任何人都可以告诉 WSDL 有什么问题吗?

I want to use Axis 2. I tried to generate the skeleton using wsdl2java also but it gives compilation issues in the generated classes. I am not able to attach the file here so I am pasting it here.

我想使用 Axis 2。我也尝试使用 wsdl2java 生成骨架,但它在生成的类中出现了编译问题。我无法在此处附加文件,因此我将其粘贴到此处。

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:impl="http://DefaultNamespace"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.apache.org/xml-soap"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      name="Test" targetNamespace="http://DefaultNamespace"> 
      <wsdl:types>
        <xsd:schema elementFormDefault="qualified"
          targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
          <import namespace="http://xml.apache.org/xml-soap" />
          <xsd:element name="serviceMethod">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="vo" type="impl:MyVo" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
          <xsd:complexType name="MyVo">
            <xsd:sequence>
              <xsd:element name="name" nillable="false" type="xsd:string" />
              <xsd:element name="params" nillable="true"
                type="apachesoap:Map" />
            </xsd:sequence>
          </xsd:complexType>
          <xsd:element name="serviceMethodResponse">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="serviceMethodReturn" type="impl:MyVo" />
              </xsd:sequence>
            </xsd:complexType>
          </xsd:element>
        </xsd:schema>
        <xsd:schema elementFormDefault="qualified"
          targetNamespace="http://xml.apache.org/xml-soap" xmlns="http://www.w3.org/2001/XMLSchema">
          <import namespace="http://DefaultNamespace" />
          <xsd:complexType name="mapItem">
            <xsd:sequence>
              <xsd:element name="key" nillable="true" type="xsd:anyType" />
              <xsd:element name="value" nillable="true" type="xsd:anyType" />
            </xsd:sequence>
          </xsd:complexType>
          <xsd:complexType name="Map">
            <xsd:sequence>
              <xsd:element maxOccurs="unbounded" minOccurs="0"
                name="item" type="apachesoap:mapItem" />
            </xsd:sequence>
          </xsd:complexType>
        </xsd:schema>
      </wsdl:types>
      <wsdl:message name="serviceMethodRequest">
        <wsdl:part element="impl:serviceMethod" name="parameters" />
      </wsdl:message>
      <wsdl:message name="serviceMethodResponse">
        <wsdl:part element="impl:serviceMethodResponse" name="parameters" />
      </wsdl:message>
      <wsdl:portType name="Test">
        <wsdl:operation name="serviceMethod">
          <wsdl:input message="impl:serviceMethodRequest" name="serviceMethodRequest" />
          <wsdl:output message="impl:serviceMethodResponse" name="serviceMethodResponse" />
        </wsdl:operation>
      </wsdl:portType>
      <wsdl:binding name="TestSOAP" type="impl:Test">
        <soap:binding style="document"
          transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="serviceMethod">
          <soap:operation soapAction="http://DefaultNamespace/serviceMethod" />
          <wsdl:input>
            <soap:body use="literal" />
          </wsdl:input>
          <wsdl:output>
            <soap:body use="literal" />
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="Test">
        <wsdl:port binding="impl:TestSOAP" name="MyWebService">
          <soap:address location="http://localhost:8080/Temp/services/MyService" />
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>

采纳答案by java_enthu

That's a problem with your install.

那是你安装的问题。

Download and verify axis2 and the axis2 eclipse plugins, make sure you've set up your AXIS2_HOME class paths.

下载并验证axis2 和axis2 eclipse 插件,确保您已经设置了AXIS2_HOME 类路径。

Sometimes it stops working for me too, and then I have to go and reinstall everything. Don't bother making bug reports to Eclipse or Apache, they are always closed as "WORKSFORME".

有时它对我也不起作用,然后我必须去重新安装所有东西。不要费心向 Eclipse 或 Apache 报告错误,它们总是以“WORKSFORME”的形式关闭。

Steps to produce code from your wsdl:

从 wsdl 生成代码的步骤:

  1. Create a dynamic web project.
  2. Create your wsdl file.
  3. Right-click on your wsdl file, select Web Services -> Generate Java Bean Skeleton
  4. Click Finish
  1. 创建一个动态 Web 项目。
  2. 创建您的 wsdl 文件。
  3. 右键单击您的 wsdl 文件,选择 Web Services -> Generate Java Bean Skeleton
  4. 单击完成

The Axis2 libraries, facets, and generated code will be added to your project automagically, and there will be no compilation problems.

Axis2 库、facet 和生成的代码将自动添加到您的项目中,并且不会出现编译问题。

回答by Hadi Tok

I had the same problem. I believe maven folder structure is causing it. I created a new project without maven and it worked. Added maven later. Also check source folders at "Java Build Path". If it is missing you will need to add it.

我有同样的问题。我相信 maven 文件夹结构是造成它的原因。我在没有 maven 的情况下创建了一个新项目并且它有效。稍后添加maven。还要检查“Java 构建路径”中的源文件夹。如果缺少,则需要添加它。

回答by Azhar Ali

I was facing the same trouble but now it has been solved. The problem is if you have a method that 'THROWS SOME KIND OF EXCEPTION', then it will cause the problem. Hence instead of throwing the error, try using try-catch block statement.

我遇到了同样的问题,但现在已经解决了。问题是,如果您有一种“抛出某种异常”的方法,那么它就会导致问题。因此,不要抛出错误,而是尝试使用 try-catch 块语句。