将外部JAXB绑定文件应用于从WSDL导入的模式元素 [英] Applying external JAXB binding file to schema elements imported from WSDL

查看:92
本文介绍了将外部JAXB绑定文件应用于从WSDL导入的模式元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的外部绑定文件中的XPath表达式无法定位导入到我的WSDL中的XML模式中的元素。

The XPath expression in my external binding files can't target the elements in my XML schemas which are imported into my WSDL.

如果我进行内联绑定,一切都会运行自定义,但我真的想拥有外部绑定文件,这样我就不会意外地覆盖(刷新)包含我的自定义的文件。

Everything runs if I do inline binding customization but I really wanted to have external binding files that way I never accidentally overwrite(refresh) the files containing my customizations.

我的绑定文件的开头:

<jaxb:bindings
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    version="2.1">
    <jaxb:bindings schemaLocation="../wsdl/localhost_7001/ExampleSessionBean/ExampleSessionBeanService.wsdl#types?schema1">
        <jaxb:bindings node="//xs:schema[@targetNamespace='urn:myExample']">

我的WSDL包含:

<types>
<xsd:schema>
<xsd:import namespace="urn:myExample" schemaLocation="http://localhost:7001/ExampleSessionBean/ExampleSessionBeanService?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://ejbs/" schemaLocation="http://localhost:7001/ExampleSessionBean/ExampleSessionBeanService?xsd=2"/>
</xsd:schema>
</types>

无论我做什么,XPath都无法在xsd:import'ed模式中找到任何内容。我得到的错误是:

No matter what I do XPath can't find anything in the xsd:import'ed schemas. The error I get is:

[ERROR] XPath evaluation of "//xs:schema[@targetNamespace='urn:myExample']" results in empty target node

我尝试通过索引号访问xs:schema命名空间,但也不起作用。看起来我的XPath表达式无法从导入的模式中访问元素...无论如何要解决这个问题吗?

I've tried accessing the xs:schema by index number instead of the namespace and that doesn't work either. It seems like my XPath expressions can't reach elements from imported schemas...is there anyway to fix this?

这是在NetBean下开发的Java SE 7项目7.2。我正在使用NetBeans来完成我所有的wsimport工作,如果这很重要,但命令输出看起来相当标准RI / Metro。

This is a Java SE 7 project being developed under NetBean 7.2. I'm using NetBeans to do all my wsimport stuff if that matters but the command output looks fairly standard for RI/Metro.

编辑:
我想通了如果我使用SCD,我可以获得外部绑定文件。此XPath示例不起作用:

I figured out that I can get an external binding file to work if I use SCD. This XPath example doesn't work:

<bindings node="//xsd:schema[@targetNamespace='urn:myExample']">
    <bindings node="//xs:complexType[@name='myType']">
        <class name="MyClass"/>
    </bindings>
</bindings>

但这个SCD示例确实如此。

But this SCD example does.

<bindings scd="x-schema::tns" xmlns:tns="urn:myExample">
    <bindings scd="~tns:myType">
        <class name="MyClass"/>
    </bindings>
</bindings>

这是一个众所周知的事情,当使用wsimport时,XPath在xjb文件中不起作用但SCD确实如此?

Is this a known thing where XPath doesn't work in xjb files when using wsimport but SCD does?

推荐答案

你应该像以下一样使用它:

you should use it like:

<jaxws:bindings node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='http://duke.example.org']">
    <jaxb:schemaBindings>
        <jaxb:package name="fromwsdl.server"/>
    </jaxb:schemaBindings>
</jaxws:bindings>

小心命名空间

它所有内容都在这里解释:
https:// jax- ws.java.net/nonav/2.1.2/docs/customizations.html

It all is explained here: https://jax-ws.java.net/nonav/2.1.2/docs/customizations.html

这篇关于将外部JAXB绑定文件应用于从WSDL导入的模式元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆