gpt4 book ai didi

java - Axis2 Web 服务和 Eclipse WSDL 创作 : Adding an axis fault to wsdl causes exception when running wsdl2java

转载 作者:行者123 更新时间:2023-11-29 06:25:24 28 4
gpt4 key购买 nike

我正在尝试使用 Apache Axis2 1.4.1 创建契约优先的 Web 服务。因为 Eclipse 有一个看起来非常完整的 wsdl 编辑器,所以我开始使用 Eclipse 的编辑器自动运行我的 wsdl。一切都很好,我可以使用 wsdl2java 生成 Java 类,Web 服务在部署时工作。但是,向 Web 服务添加异常或错误会导致出现错误,指出 Element QName 对于 Fault 为 null。有谁知道这可能是什么原因?检查 wsdl 也没有给我任何直接的答案。似乎错误/异常的定义与其他元素一样。

这是命令和堆栈跟踪:

>d:\axis2-1.4.1\bin\wsdl2java.bat -o src-test -ss -uri JavaIntegrationModule.wsdl
Using AXIS2_HOME: D:\axis2-1.4.1
Using JAVA_HOME: D:\Java\jdk1.5.0_14
Retrieving document at 'JavaIntegrationModule.wsdl'.
[INFO] The src-test\src\org\example\www\javaintegrationmodule\JavaIntegrationModuleSkeleton.java file cannot be overwritten.
[INFO] The src-test\src\org\example\www\javaintegrationmodule\JavaIntegrationModuleMessageReceiverInOut.java file cannot be overwritten.
D:\>d:\axis2-1.4.1\bin\wsdl2java.bat -o src-test -ss -uri JavaIntegrationModule.wsdl
Using AXIS2_HOME: D:\axis2-1.4.1
Using JAVA_HOME: D:\Java\jdk1.5.0_14
Retrieving document at 'JavaIntegrationModule.wsdl'.
D:\>d:\axis2-1.4.1\bin\wsdl2java.bat -o src-test -ss -uri JavaIntegrationModule.wsdl
Using AXIS2_HOME: D:\axis2-1.4.1
Using JAVA_HOME: D:\Java\jdk1.5.0_14
Retrieving document at 'JavaIntegrationModule.wsdl'.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: org.apache.axis2.wsdl.codegen.CodeGenerationException: jav
a.lang.RuntimeException: Element QName is null for getSolutionByIdFault!
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: Element QName is null for getSolutionByIdFault
!
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.emitSkeleton(AxisServiceBasedMultiLanguageEmitter.java
:1370)
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:253)
... 2 more
Caused by: java.lang.RuntimeException: Element QName is null for getSolutionByIdFault!
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.getFaultParamElements(AxisServiceBasedMultiLanguageEmi
tter.java:2829)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.getFaultElement(AxisServiceBasedMultiLanguageEmitter.j
ava:2748)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.generateMethodElement(AxisServiceBasedMultiLanguageEmi
tter.java:2269)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.loadOperations(AxisServiceBasedMultiLanguageEmitter.ja
va:2151)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.createDOMDocumentForSkeleton(AxisServiceBasedMultiLang
uageEmitter.java:2065)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.writeSkeleton(AxisServiceBasedMultiLanguageEmitter.jav
a:1991)
at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.emitSkeleton(AxisServiceBasedMultiLanguageEmitter.java
:1327)
... 3 more

和 WSDL 文件:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/JavaIntegrationModule/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="JavaIntegrationModule" targetNamespace="http://www.example.org/JavaIntegrationModule/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/JavaIntegrationModule/">
<xsd:element name="getSolutionById">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getSolutionByIdResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getSolutionByIdFault">
<xsd:complexType>
<xsd:sequence>

<xsd:element name="getSolutionByIdFault"
type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getSolutionByIdRequest">
<wsdl:part element="tns:getSolutionById" name="parameters"/>
</wsdl:message>
<wsdl:message name="getSolutionByIdResponse">
<wsdl:part element="tns:getSolutionByIdResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="getSolutionByIdFault">
<wsdl:part name="parameters" element="tns:getSolutionByIdFault"></wsdl:part>
</wsdl:message>
<wsdl:portType name="JavaIntegrationModule">
<wsdl:operation name="getSolutionById">
<wsdl:input message="tns:getSolutionByIdRequest"/>
<wsdl:output message="tns:getSolutionByIdResponse"/>
<wsdl:fault name="fault" message="tns:getSolutionByIdFault"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="JavaIntegrationModuleSOAP" type="tns:JavaIntegrationModule">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getSolutionById">
<soap:operation soapAction="http://www.example.org/JavaIntegrationModule/getSolutionById"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="JavaIntegrationModule">
<wsdl:port binding="tns:JavaIntegrationModuleSOAP" name="JavaIntegrationModuleSOAP">
<soap:address location="http://www.example.org/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

最佳答案

我想我现在已经自己解决了这个问题。似乎出于某种原因,eclipse WSDL 编辑器没有将错误添加到 WSDL 的绑定(bind)部分。

所以当我添加:

<wsdl:fault name="fault">
<soap:fault use="literal" name="fault" />
</wsdl:fault>

对于绑定(bind),它编译得很好。

现在完整的 wsdl 是:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/JavaIntegrationModule/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="JavaIntegrationModule" targetNamespace="http://www.example.org/JavaIntegrationModule/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/JavaIntegrationModule/">
<xsd:element name="getSolutionById">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getSolutionByIdResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getSolutionByIdFault">
<xsd:complexType>
<xsd:sequence>

<xsd:element name="getSolutionByIdFault"
type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:schema>
</wsdl:types>
<wsdl:message name="getSolutionByIdRequest">
<wsdl:part element="tns:getSolutionById" name="parameters"/>
</wsdl:message>
<wsdl:message name="getSolutionByIdResponse">
<wsdl:part element="tns:getSolutionByIdResponse" name="parameters"/>
</wsdl:message>

<wsdl:message name="getSolutionByIdFault">
<wsdl:part name="parameters" element="tns:getSolutionByIdFault"></wsdl:part>
</wsdl:message>
<wsdl:portType name="JavaIntegrationModule">
<wsdl:operation name="getSolutionById">
<wsdl:input message="tns:getSolutionByIdRequest"/>
<wsdl:output message="tns:getSolutionByIdResponse"/>

<wsdl:fault name="fault" message="tns:getSolutionByIdFault"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="JavaIntegrationModuleSOAP" type="tns:JavaIntegrationModule">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getSolutionById">
<soap:operation soapAction="http://www.example.org/JavaIntegrationModule/getSolutionById"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="fault">
<soap:fault use="literal" name="fault" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="JavaIntegrationModule">
<wsdl:port binding="tns:JavaIntegrationModuleSOAP" name="JavaIntegrationModuleSOAP">
<soap:address location="http://www.example.org/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

关于java - Axis2 Web 服务和 Eclipse WSDL 创作 : Adding an axis fault to wsdl causes exception when running wsdl2java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2343514/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com