CXF wsdl2java - 映射命名空间和包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21639755/
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-08-13 09:48:46  来源:igfitidea点击:

CXF wsdl2java - mapping namespaces and packages

javamappingcxfwsdl2java

提问by Roman Kos

I'm using CXF's wsdl2java tool to create a java web service. I have a wsdl file and a few XSD files and I know that it's possible to use a binding file to map namespaces and packages. My binding file looks like this:

我正在使用 CXF 的 wsdl2java 工具来创建 Java Web 服务。我有一个 wsdl 文件和一些 XSD 文件,我知道可以使用绑定文件来映射命名空间和包。我的绑定文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" jaxb:version="2.0">
    <jaxb:bindings schemaLocation="SchemeA.xsd" node="/xsd:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="com.test.package.a" />
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="SchemeB.xsd" node="/xsd:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="com.test.package.b" />
        </jaxb:schemaBindings>
    </jaxb:bindings>
    <jaxb:bindings schemaLocation="SchemeC.xsd" node="/xsd:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="com.test.package.c" />
        </jaxb:schemaBindings>
    </jaxb:bindings>
</jaxb:bindings>

My files:

我的文件:

  • A.wsdl (imports all .xsd files)
  • SchemeA.xsd
  • SchemeB.xsd
  • SchemeC.xsd
  • A.wsdl(导入所有 .xsd 文件)
  • 方案A.xsd
  • 方案B.xsd
  • 方案C.xsd

It works great for everything in this XSD schemes but not for wsdl's definition. I mean at the end my packages looks like this:

它适用于此 XSD 方案中的所有内容,但不适用于 wsdl 的定义。我的意思是最后我的包裹看起来像这样:

  • com.test.package.a
  • com.test.package.b
  • com.test.package.c
  • https.package_test_com.a.service
  • com.test.package.a
  • com.test.package.b
  • com.test.package.c
  • https.package_test_com.a.service

The last line bother me, and I would like it to look like this: com.test.package.a.service

最后一行打扰了我,我希望它看起来像这样:com.test.package.a.service

采纳答案by vbazaga86

The binding file is used by jaxb that manages bindings of paramater and responses but webservice is directly managed by cxf or jax-ws so you will need to specify this binding with -p option of wsdl2java as specified here http://cxf.apache.org/docs/wsdl-to-java.html

绑定文件由 jaxb 使用,它管理参数和响应的绑定,但 webservice 直接由 cxf 或 jax-ws 管理,因此您需要使用此处指定的 wsdl2java 的 -p 选项指定此绑定http://cxf.apache。 org/docs/wsdl-to-java.html