将JAXB和JAXWS组合为导入的XML Schema [英] Combine JAXB and JAXWS for an imported XML Schema

查看:125
本文介绍了将JAXB和JAXWS组合为导入的XML Schema的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用wsimport时为WSDL中的导入XSD指定JAXB绑定?

How can I specify a JAXB Binding for an imported XSD within a WSDL when using wsimport?

我尝试了以下绑定,这会导致错误XPath评估/ / xs:element [@ name ='isFoobar']导致空目标节点。

I tried following binding, which causes the error "XPath evaluation of //xs:element[@name='isFoobar'] results in an empty target node".

<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" wsdlLocation="example.wsdl"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
    <jaxws:bindings node="wsdl:definitions">
        <jaxws:bindings node="wsdl:types" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
            <jaxws:bindings
                node="//xs:schema[@targetNamespace='http://www.example.org/']">
                <jaxb:globalBindings>
                    <xjc:serializable uid="10000001" />
                </jaxb:globalBindings>
                <jaxb:bindings
                    node="//xs:element[@name='isFoobar']">
                    <jaxb:typesafeEnumClass name="IsFoobar">
                        <jaxb:typesafeEnumMember value="01" name="TRUE" />
                        <jaxb:typesafeEnumMember value="02" name="FALSE" />
                    </jaxb:typesafeEnumClass>
                </jaxb:bindings>
            </jaxws:bindings>
        </jaxws:bindings>
    </jaxws:bindings>
</jaxws:bindings>

任何想法?

推荐答案

我之前做了类似的事情,我认为您需要指定要使用XPath选择的节点,如下所示:

I did something similar ages ago, I think you need to specify the node to select with XPath as follows:

//xs:element[@name='isFoobar']/xs:complexType

或将xs:complexType替换为您在此处使用的任何类型。希望它能解决你的问题。

Or replace xs:complexType with whatever kind of type you are using here. Hopefully it will fix your probelm.

这篇关于将JAXB和JAXWS组合为导入的XML Schema的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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