wsdl2java jaxbelement<string> instead of string

本文介绍如何通过自定义binding文件解决使用cxf的wsdl2java插件生成的Java类中出现不期望的JAXBElement类型问题。通过配置-b参数及my_binding.xml文件,可以避免String等简单类型被包装成JAXBElement。

    以前做了个工具,使用cxf的wsdl2java插件,在maven工程中,同时加入manifest.mf文件模板,将wsdl文件打包为bundle化jar包,参考http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html,bundle化使用模板,修改manifest.mf文件。

    最近在使用一个wsdl文件生成jar文件的过程中,发现期望出现String类型的成为了如下的JAXBElement<String>

protected JAXBElement<String> requestStatusDescription;
    开始网上搜,找到 http://stackoverflow.com/questions/12508741/jaxb-generating-jaxbelementstring-instead-of-string,即使用-b命令,并且使用自定义Jaxb定义,参考 http://cxf.apache.org/docs/wsdl-to-java.html,有如下描述:

Q: How do I pass the binding file to wsdl2java?

A: If you are using wsdl2java via command line tool:

wsdl2java HelloWorld.wsdl -b my_binding.xml

    于是修改pom文件,添加-b参数,并添加自定义binding文件

<extraargs>
    <extraarg>-autoNameResolution</extraarg>
    <extraarg>-b</extraarg>
    <extraarg>my_binding.xml</extraarg>  
</extraargs>

my_binding.xml如下:

<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
	<jaxb:bindings>
		<jaxb:globalBindings generateElementProperty="false" />
	</jaxb:bindings>
</jaxb:bindings>


 


 

Port type AnalyticsEnginePort CreateAnalyticsModules Description: Add one or more analytics modules to an existing VideoAnalyticsConfiguration. The available supported types can be retrieved via GetSupportedAnalyticsModules, where the Name of the supported AnalyticsModules correspond to the type of an AnalyticsModule instance. Pass unique module names which can be later used as reference. The Parameters of the analytics module must match those of the corresponding AnalyticsModuleDescription. Although this method is mandatory a device implementation may not support adding modules. Instead it can provide a fixed set of predefined configurations via the media service functions GetCompatibleVideoAnalyticsConfigurations and GetAnalyticsConfigurations. The device shall ensure that a corresponding analytics engine starts operation when a client subscribes directly or indirectly for events produced by the analytics or rule engine or when a client requests the corresponding scene description stream. An analytics module must be attached to a Video source using the media profiles before it can be used. In case differing analytics configurations are attached to the same profile it is undefined which of the analytics module configuration becomes active if no stream is activated or multiple streams with different profiles are activated at the same time. SOAP action: http://www.onvif.org/ver20/analytics/wsdl/CreateAnalyticsModules Input: [CreateAnalyticsModules] ConfigurationToken [ReferenceToken] Reference to an existing VideoAnalyticsConfiguration. AnalyticsModule - unbounded; [Config] Name - required; [string] Name of the configuration. Type - required; [QName] The Type attribute specifies the type of rule and shall be equal to value of one of Name attributes of ConfigDescription elements returned by GetSupportedRules and GetSupportedAnalyticsModules command. Parameters [ItemList] List of configuration parameters as defined in the corresponding description. SimpleItem - optional, unbounded; Value name pair as defined by the corresponding description. Name - required; [string] Item name. Value - required; [anySimpleType] Item value. The type is defined in the corresponding description. ElementItem - optional, unbounded; Complex value structure. Name - required; [string] Item name. Extension - optional; [ItemListExtension] Output: [CreateAnalyticsModulesResponse]描述一下这个函数干嘛的
最新发布
09-27
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值