【问题标题】:Generate JAX-WS Source NullPointerException生成 JAX-WS 源 NullPointerException
【发布时间】:2012-07-07 08:38:16
【问题描述】:

我正在尝试从我已经创建的 WSDL 定义中生成 Java 服务类。我目前的问题是它失败并显示以下消息,仅此而已:

Unable to generate JAX-WS Source.

Reason:
java.lang.NullPointerException

(是的~为了冗长)

我使用的是基于 Eclipse 3.6.1 的 MuleStudio 1.3.0。我已经尝试从 Mule 的组件和直接从 WSDL 创建这些类,但我得到了同样的错误。

我故意混淆了 WSDL,它正确地开始抛出验证错误。这意味着它正在读取文件并正确解析它。不知道接下来会发生什么。

我该如何解决这个问题?

以下是我的 wsdl 文件供参考:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://tempuri.org/ListenerService/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    name="ListenerService"
    targetNamespace="http://tempuri.org/ListenerService/">
    <!-- types -->
    <wsdl:types>
        <!-- Generic TransactionLog entities -->
        <xsd:schema targetNamespace="http://tempuri.org/ListenerService/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <xsd:simpleType name="LevelEnumeration">
                <xsd:restriction base="xsd:normalizedString">
                    <xsd:enumeration value="Debug" />
                    <xsd:enumeration value="Info" />
                    <xsd:enumeration value="Warning" />
                    <xsd:enumeration value="Error" />
                    <xsd:enumeration value="Fatal" />
                </xsd:restriction>
            </xsd:simpleType>

            <xsd:complexType name="LogEntry">
                <sequence>
                    <xsd:element name="CorrelationToken" type="xsd:normalizedString"/>
                    <xsd:element name="SystemId" type="xsd:normalizedString"/>
                    <xsd:element name="Level" type="tns:LevelEnumeration"/>
                    <xsd:element name="Description" type="xs:string" />
                    <xsd:element name="RecordData" type="xs:string" />
                    <xsd:element name="Timestamp" type="xs:dateTime" />
                </sequence>
            </xsd:complexType>

            <!-- Service Specific Types -->
            <xsd:simpleType name="GenericResponseStatusEnumeration">
                <xsd:restriction base="xsd:normalizedString">
                    <xsd:enumeration value="Success" />
                    <xsd:enumeration value="Error" />
                </xsd:restriction>
            </xsd:simpleType>
            <xsd:complexType name="ListenerServiceGenericResponse">
                <sequence>
                    <xsd:element name="Status" type="tns:GenericResponseStatusEnumeration" />
                    <xsd:element name="Detail" type="xsd:string" minOccurs="0" maxOccurs="1" />
                </sequence>
            </xsd:complexType>

            <xsd:element name="LogEntry" type="tns:LogEntry" />
            <xsd:element name="ServiceResponse" type="tns:ListenerServiceGenericResponse" />
        </xsd:schema>
    </wsdl:types>

    <!-- service message types -->
    <wsdl:message name="SubmitLogRequest">
        <wsdl:part name="LogEntry" type="tns:LogEntry" />
    </wsdl:message>
    <wsdl:message name="SubmitLogResponse">
        <wsdl:part name="Response" type="tns:ListenerServiceGenericResponse" />
    </wsdl:message>

    <!-- service messages -->
    <wsdl:portType name="ListenerService">
        <wsdl:operation name="SubmitLog">
            <wsdl:input message="tns:SubmitLogRequest" />

            <!-- TODO: Remove this to make it a one-way operation -->
            <wsdl:output message="tns:SubmitLogResponse" />
        </wsdl:operation>
    </wsdl:portType>

    <!-- service bindings -->
    <wsdl:binding name="ListenerServiceSOAP">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="SubmitLog">
            <soap:operation soapAction="http://tempuri.org/ListenerService/SubmitLog" />
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="ListenerService">
        <wsdl:port binding="tns:ListenerServiceSOAP" name="ListenerServiceSOAP">
            <soap:address location="http://tempuri.org" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

【问题讨论】:

  • 我会尝试从命令行直接在您的 Wsdl 上调用 jaxws wsimport 命令。我相信它现在随 JDK 一起提供,因此您甚至不必下载它。您可能遇到了一个已在更高版本的 wsimport 中修复的错误。
  • @davidfrancis 谢谢,我会在这里尝试更新。
  • @davidfrancis 谢谢,这实际上是我的问题的解决方案。从命令行运行它给了我很多关于 WSDL 问题在哪里的信息,但我仍然不明白为什么它不给我任何关于 Eclipse 的反馈。我会更新问题以反映这一点。再次感谢!
  • @davidfrancis 好吧,不,我改变了主意。你回答了我原来的问题,改变它会完全改变问题的范围,所以我不会那样做。请随时发布您的反馈作为答案,以便我接受它作为解决这些问题的正确方法。
  • 好的,很高兴能帮上忙——有点!

标签: java eclipse wsdl jax-ws mule


【解决方案1】:

我会尝试从命令行直接在 Wsdl 上调用 jaxws wsimport 命令。 我相信它现在随 JDK 一起提供,因此您甚至不必下载它。
您可能遇到了一个已在更高版本的 wsimport 中修复的错误。

【讨论】:

  • PS 在 Eclipse 中,您有一个控制台视图,它有一个下拉框可以切换到多个不同的控制台。也许其中之一有一些 JAX-WS 信息?或者有主 Eclipse 日志文件。
  • 不幸的是,我无法找到 JAX-WS 的控制台视图,但是从命令行运行 wsimport 工具指出了我在 wsdl 文件中遇到的一些问题。因此,我能够修复它们并生成文件(然后我必须将其导入到我的项目中)。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-04
  • 1970-01-01
  • 2012-11-06
相关资源
最近更新 更多