当前位置: 首页 > 知识库问答 >
问题:

使用apache CXF 3从wsdl生成Web服务客户端出错

夏俊杰
2023-03-14

我试图从WSDL生成web服务客户机,我对这一点一无所知,所以无法找出错误。我试过:

wsimport -keep path-to-wsdl

这给了我一个错误:

C:\WINDOWS\system32>wsimport -keep  E:\NIEsocketWork\sdl.wsdl
parsing WSDL...


[WARNING] src-resolve.4.2: Error resolving component 'tns:GetMerchantRateRequest'. It was detected that 'tns:GetMerchantRateRequest' is in namespace 'http://www.fexcodcc.com/DCC20071126', but components from this namespace are not referenceable from schema document 'file:/E:/NIEsocketWork/sdl.wsdl#types?schema1'. If this is the incorrect namespace, perhaps the prefix of 'tns:GetMerchantRateRequest' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/E:/NIEsocketWork/sdl.wsdl#types?schema1'.
  line 20 of file:/E:/NIEsocketWork/sdl.wsdl#types?schema1

[WARNING] src-resolve: Cannot resolve the name 'tns:GetMerchantRateRequest' to a(n) 'type definition' component.
  line 20 of file:/E:/NIEsocketWork/sdl.wsdl#types?schema1

[ERROR] undefined simple or complex type 'tns:GetMerchantRateRequest'
  line 20 of file:/E:/NIEsocketWork/sdl.wsdl

[ERROR] undefined simple or complex type 'tns:GetMerchantRateResponse'
  line 26 of file:/E:/NIEsocketWork/sdl.wsdl

[ERROR] undefined simple or complex type 'tns:GetCardRateRequest'
  line 79 of file:/E:/NIEsocketWork/sdl.wsdl

[ERROR] undefined simple or complex type 'tns:GetCardRateResponse'
  line 85 of file:/E:/NIEsocketWork/sdl.wsdl

Exception in thread "main" com.sun.tools.internal.ws.wscompile.AbortException
        at com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:129)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2283)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:183)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:126)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:429)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:190)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:168)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159)
        at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)

我还尝试了apache cxf 3.1.1在eclipse中生成Web服务客户端,但得到这个错误:

Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -client -d C:\Users\Hamza\GalileoWorkspace\NIDCCFexco\.cxftmp/src -classdir C:\Users\Hamza\GalileoWorkspace\NIDCCFexco\build\classes -p http://www.fexcodcc.com/DCC20071126=com.fexcodcc.dcc20071126 -impl -validate -exsh false -dns true -dex true -wsdlLocation file:///E:/NIEsocketWork/sdl.wsdl -verbose -defaultValues -fe jaxws -db jaxb -wv 1.1 file:/E:/NIEsocketWork/sdl.wsdl
wsdl2java - Apache CXF 3.1.1


WSDLToJava Error: 
 Summary:  Failures: 4, Warnings: 0

 <<< ERROR! 
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateOut> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateResult> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetCardRateOut> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetCardRateResult> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetCardRateIn> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetCardRate> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateIn> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetMerchantRate> can not be found in the schemas



org.apache.cxf.tools.common.ToolException: 
 Summary:  Failures: 4, Warnings: 0

 <<< ERROR! 
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateOut> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateResult> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetCardRateOut> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetCardRateResult> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetCardRateIn> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetCardRate> can not be found in the schemas
Part <parameters> in Message <{http://www.fexcodcc.com/DCC20071126}GetMerchantRateIn> referenced Type <{http://www.fexcodcc.com/DCC20071126}GetMerchantRate> can not be found in the schemas


    at org.apache.cxf.tools.validator.internal.WSDL11Validator.isValid(WSDL11Validator.java:139)
    at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.validate(JAXWSDefinitionBuilder.java:207)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:204)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
    at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:415)
    at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
    at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)

我的WSDL文件是:

    <?xml version="1.0" encoding="utf-8" ?>

<wsdl:definitions targetNamespace="http://www.fexcodcc.com/DCC20071126" 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
xmlns:tns="http://www.fexcodcc.com/DCC20071126" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsi="http://ws-i.org/schemas/conformanceClaim/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<wsdl:documentation>DCC Gateway (Provides functionality to make requests to the DCC for availability)</wsdl:documentation>

<!-- Types --> <wsdl:types>

<xsd:schema elementFormDefault="qualified" targetNamespace="http:// www.fexcodcc.com/DCC20071126" xmlns:dhs="urn:dhs">
<!-- Type definitions -->
<xsd:element name="GetMerchantRate"> <xsd:complexType>
<xsd:sequence>
<xsd:element name="GetMerchantRateRequest" type="tns:GetMerchantRateRequest" minOccurs="1" maxOccurs="1"/>

</xsd:sequence> </xsd:complexType>
</xsd:element>
<xsd:element name="GetMerchantRateResult"> <xsd:complexType>
<xsd:sequence>
<xsd:element name="GetMerchantRateResponse" type="tns:GetMerchantRateResponse" minOccurs="1" maxOccurs="1" />

</xsd:sequence> </xsd:complexType>
</xsd:element>
<!-- Complex type definitions -->

<xsd:complexType name="GetMerchantRateResponse"> <xsd:sequence>

<xsd:element name="ReferenceNumber" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="ExchangeRate" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="FgnCurCode" type="xsd:string" minOccurs="0" maxOccurs="1" />



<xsd:element name="FgnAmount" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="DccOffered" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="ValidHours" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="MarginRatePercentage" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="ExchangeRateSourcename" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="CommissionPercentage" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="ExchangerateSourceTimestamp" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="MinorUnits" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="ResponseCode" type="xsd:string" minOccurs="1" maxOccurs="1" />

</xsd:sequence> </xsd:complexType>

<xsd:complexType name="GetMerchantRateRequest"> <xsd:sequence>

<xsd:element name="ReferenceNumber" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="MerchantId" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="Acquirer" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="FgnCurCode" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="BaseAmount" type="xsd:string" minOccurs="0" maxOccurs="1" />

</xsd:sequence> </xsd:complexType>

<xsd:element name="GetCardRate"> <xsd:complexType>
<xsd:sequence>

<xsd:element name="GetCardRateRequest" type="tns:GetCardRateRequest" minOccurs="1" maxOccurs="1" />

</xsd:sequence> </xsd:complexType>
</xsd:element>
<xsd:element name="GetCardRateResult"> <xsd:complexType>
<xsd:sequence>
<xsd:element name ="GetCardRateResponse" type="tns:GetCardRateResponse" minOccurs="1" maxOccurs="1" />

</xsd:sequence> </xsd:complexType>
</xsd:element>

<!-- Complex type definitions --> <xsd:complexType name="GetCardRateResponse">
<xsd:sequence>
<xsd:element name="ReferenceNumber" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="ExchangeRate" type="xsd:string" minOccurs="0" maxOccurs="1" />


<xsd:element name="FgnCurCode" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="FgnAmount" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="DccOffered" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="ValidHours" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="MarginRatePercentage" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="ExchangeRateSourceName" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="CommissionPercentage" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="ExchangeRateSourceTimestamp" type="xsd:string" minOccurs="0" maxOccurs="1" />

<xsd:element name="MinorUnits" type="xsd:string" minOccurs="0" maxOccurs="1" /><xsd:element name="ResponseCode" type="xsd:string" minOccurs="1" maxOccurs="1" />

</xsd:sequence> </xsd:complexType>

<xsd:complexType name="GetCardRateRequest"> <xsd:sequence>

<xsd:element name="ReferenceNumber" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="CardId" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="MerchantId" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="Acquirer" type="xsd:string" minOccurs="1" maxOccurs="1" />

<xsd:element name="BaseAmount" type="xsd:string" minOccurs="0" maxOccurs="1" />

</xsd:sequence> </xsd:complexType>

</xsd:schema> </wsdl:types>

<!-- Dhs Server Messages --> <wsdl:message name="GetMerchantRateIn">

<wsdl:part name="parameters" element="tns:GetMerchantRate" /> </wsdl:message>
<wsdl:message name="GetMerchantRateOut">
<wsdl:part name="parameters" element="tns:GetMerchantRateResult" /> </wsdl:message>
<wsdl:message name="GetCardRateIn">
<wsdl:part name="parameters" element="tns:GetCardRate" /> </wsdl:message>
<wsdl:message name="GetCardRateOut">

<wsdl:part name="parameters" element="tns:GetCardRateResult" /> </wsdl:message>
<!-- End of Dhs Server Messages -->


<!-- Port types --> <wsdl:portType name="DHS">
<wsdl:operation name="getMerchantRate">

<wsdl:documentation>Get Exchange Rate for merchant</wsdl:documentation> <wsdl:input message="tns:GetMerchantRateIn" />

<wsdl:output message="tns:GetMerchantRateOut" /> </wsdl:operation>
<wsdl:operation name="getCardRate">
<wsdl:documentation>Get Dynamic Currency conversion</wsdl:documentation> <wsdl:input message="tns:GetCardRateIn" />

<wsdl:output message="tns:GetCardRateOut" /> </wsdl:operation>

<!-- End of Dhs Server Operations --> </wsdl:portType>

<!-- WSDL bindings -->

<wsdl:binding name="DHS12" type="tns:DHS"> <wsdl:documentation>

<wsi:Claim conformsTo="http://ws-i.org/profiles/basic/1.1" /> </wsdl:documentation>

<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="getMerchantRate">
<soap12:operation soapAction="http://www.fexcodcc.com/DCC20071126/ getMerchantRate" style="document" />
<wsdl:input>
<soap12:body use="literal" /> </wsdl:input>
<wsdl:output>
<soap12:body use="literal" /> </wsdl:output>
</wsdl:operation>
<wsdl:operation name="getCardRate">

<soap12:operation soapAction="http://www.fexcodcc.com/DCC20071126/ getCardRate" style="document" />
<wsdl:input>
<soap12:body use="literal" /> </wsdl:input>
<wsdl:output>
<soap12:body use="literal" /> </wsdl:output>

</wsdl:operation> </wsdl:binding>
<!-- WSDL service -->

<wsdl:service name="DHS">

<wsdl:documentation> DHS Server(Provides functionality to make DCC availability requests)</wsdl:documentation>
<wsdl:port name="DHS12" binding="tns:DHS12">

<soap12:address location="dhstest2.fexcodccapps.com/axis2/services/DHS"  />
</wsdl:port>

</wsdl:service>
</wsdl:definitions>

请帮我找出任何方式的错误,无论是wsimport还是apache cxf。我会非常感激的。

共有1个答案

钮誉
2023-03-14

在模式声明中,斜杠后面的空格太多:http://www.fexcodcc。com/DCC20071126,而不是http://www.fexcodcc.com/DCC20071126.

尝试删除该空间,它会验证。

 类似资料:
  • 尝试在Eclipse中使用向导/web服务/web服务客户机从现有服务器生成web服务客户机时。Net Web服务的WSDL,我遇到了以下错误:“向导WSDL验证已禁用。”,向导无法继续返回主页,因为:找不到服务器,并且WebServiceProject不存在。选择现有项目或使用首选项配置服务器运行时。我能做些什么来解决这个问题?谢谢

  • 问题内容: 我正在尝试使用JDK 6工具为某些SOAP Web服务生成客户端。WSDL由.NET 2.0应用程序生成。对于.NET 3.X应用程序,它可以正常工作。 当我跑步 它显示了一些错误消息,如下所示: [错误]具有相同名称“ mypackage.SomeClass”的类/接口已在使用中。使用类自定义解决此冲突。行?? 的HTTP://为MyService WSDL 当我使用Axis 1.4

  • 问题内容: Axis2和Eclipse是否可以生成Web Service客户端,并使其使用包中已经具有的Java类型,而不是创建自己的类型。原因当然是如果我已经创建了类型A,并且它创建了它自己的类型AI,则不能仅将类型A的变量分配给类型B的变量。 wsdl是从部署到应用程序服务器的Web服务生成的。如果无法从中生成它,则可以从已经存在的Java文件中生成一个客户端。 问题答案: 如果您确实想重用现

  • 我正在尝试使用Axis2构建的web服务,因此我遵循以下示例创建客户机代码。 这个错误的原因是什么?

  • 问题内容: 我正在尝试使用CXF创建Web服务客户端以使用WCF Web服务。当我使用wsdl2java时,它将生成具有JAXBElement类型而不是String的对象。 我读到有关使用jaxb bindings.xml文件设置generateElementProperty =“ false”来尝试解决此问题的信息,但是我使用的Web服务包含7个导入的架构。 如何在所有七个模式上指定,还是可以将

  • 我需要创建web服务客户端,这家提供服务的公司向我们发送wsdl文件。我有wsdl文件、用户名和密码、服务url和txt文件,其中包含一些密钥,比如“20A9 38 4e 82 3a 94 d1…”。服务器有自签名证书,我试图通过InstallCert获取证书。java,使用keytool等生成密钥库。当我使用axis2 wsdl2java从wsdl生成客户端时,它会生成客户端,但在生成过程结束时