无法从 WSDL 生成存根/java 骨架

发布于 2024-11-26 15:48:13 字数 4246 浏览 0 评论 0原文

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

我想使用 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>

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?

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.

<?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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

凶凌 2024-12-03 15:48:13

那是你的安装有问题。

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

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

从 wsdl 生成代码的步骤:

  1. 创建动态 Web 项目。
  2. 创建您的 wsdl 文件。
  3. 右键单击您的 wsdl 文件,选择 Web Services ->生成 Java Bean 骨架
  4. 单击完成

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

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.

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".

Steps to produce code from your 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

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

鱼忆七猫命九 2024-12-03 15:48:13

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

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.

闻呓 2024-12-03 15:48:13

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文