有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java拒绝名称空间仅在文件扩展名(最后一个点后的部分)上不同的WSDL合法吗?

我有一个复杂的web应用程序,它使用许多web服务。我得开始用新的了。这个新服务的WSDL定义了一个目标名称空间,该名称空间与旧WSDL中使用的名称空间几乎相同。只有最后一个点后面的部分不同

JAXB推导出的包名对于它们是相同的,并且从第二个包生成的ObjectFactory覆盖了另一个包

例如,一个wsdl有一个目标命名空间“http://foo.com/a.b.c”,另一个wsdl有“http://foo.com/a.b.c_2”。那么java包的名称将是com。福。a、 b表示两个名称空间,这是一种冲突

我检查了JAXB规范,发现了这个(https://download.oracle.com/otn-pub/jcp/jaxb-2.0-fr-eval-oth-JSpec/jaxb-2_0-fr-spec.pdf?AuthParam=1542978637_f7c18a1892b0ff022071acdab6259bdd):

D.5.1 Mapping from a Namespace URI An XML namespace is represented by a URI. Since XML Namespace will be mapped to a Java package, it is necessary to specify a default mapping from a URI to a Java package name. The URI format is described in [RFC2396]. The following steps describe how to map a URI to a Java package name. The example URI, http://www.acme.com/go/espeak.xsd, is used to illustrate each step.

  1. Remove the scheme and ":" part from the beginning of the URI, if present. Since there is no formal syntax to identify the optional URI scheme, restrict the schemes to be removed to case insensitive checks for schemes “http” and “urn”.

    //www.acme.com/go/espeak.xsd

  2. Remove the trailing file type, one of .?? or .??? or .html.

    //www.acme.com/go/espeak

    ...

我这边可能有解决办法,但我希望web服务提供商通过使用“适当的”名称空间来“纠正”这种情况,这些名称空间仅在最后一部分(JAXB术语中的文件扩展名?)没有区别

我正在为“我的案子”寻找论据


共 (1) 个答案

  1. # 1 楼答案

    请参阅Namespaces in XML 1.0§2.3 Comparing URI References

    URI references identifying namespaces are compared when determining whether a name belongs to a given namespace, and whether two names belong to the same namespace. [Definition: The two URIs are treated as strings, and they are identical if and only if the strings are identical, that is, if they are the same sequence of characters. ] The comparison is case-sensitive, and no %-escaping is done or undone.

    如果名称空间“仅在文件扩展名上不同”,则这些名称空间是不同的。如果您的工具为它们生成相同的包,那么问题就在您这边,而不是WSDL作者那边

    所以不,你没有很好的理由支持“你的案子”,抱歉

    解决方法很简单:只需为每个命名空间配置目标包。例如,请参见以下问题:

    CXF: How to change package of WSDL imported XML Schema using JAXB external binding file?