使用jaxb,我尝试读取xml文件只有xml文件中的一些元素很有趣,所以我想跳过很多元素
xml我尝试阅读
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2010 rel. 3 sp1 (http://www.altova.com)-->
<flx:ModeleREP xsi:schemaLocation="urn:test:mod_rep.xsd mod_rep.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flx="urn:test:mod_rep.xsd">
<flx:DocumentHeader>
<flx:Identification v="04489"/>
</flx:DocumentHeader>
<flx:TimeSeries>
<flx:Identification v="test1a"/>
<flx:BusinessType v="A01"/>
<flx:Product v="123a"/>
<flx:ResourceObject codingScheme="N" v="testa"/>
<flx:Period>
<flx:TimeInterval v="2011-07-02T00:00/2011-07-16T00:00"/>
<flx:Resolution v="PT2H"/>
<flx:Pt>
<flx:P v="1"/>
<flx:Q unitCode="String" v="1.0"/>
<flx:A currencyIdentifier="String" v="195.0"/>
</flx:Pt>
</flx:Period>
</flx:TimeSeries>
<flx:TimeSeries>
<flx:Identification v="test2a"/>
<flx:BusinessType v="A01"/>
<flx:Product v="a123b"/>
<flx:ResourceObject codingScheme="N" v="test2"/>
<flx:Period>
<flx:TimeInterval v="2011-07-02T00:00/2011-07-16T00:00"/>
<flx:Resolution v="PT2H"/>
<flx:Pt>
<flx:P v="1"/>
<flx:Q unitCode="String" v="1.0"/>
<flx:A currencyIdentifier="String" v="195.0"/>
</flx:Pt>
<flx:Pt>
<flx:P …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用RSA 7.5和Websphere 7服务器开发IBM JAX_WS Web服务.由于我是初学者,因此我遵循Java类第一种方法,即我首先创建Java类,然后生成WSDL文件.
当我尝试创建wsdl文件时,我得到一个例外:
java.security.PrivilegedActionException:com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:IllegalAnnotationsException的1个计数Class有两个同名的属性"planId"
我的班级在这里看起来像这样:
public class MemberDetails{
@XMLElement(required=true)
private String planId;
//public getters and setters for the planId;
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么会发生这种异常.通过谷歌搜索,我尝试了一些替代方案来解决它,但没有一个为我工作:(
注意:
这是我在整个工作区中使用的唯一注释.我不确定这是否依赖于其他一些注释.但我尝试了一些诸如@XMLElement(name ="Plan",required = true),@ XMLType等,但每次我都得到这个例外.
这个例外是在wsgen期间发生的.(java.lang.reflect.InvocationTargetException)
编辑
基本上,当我们从java服务方法创建一个wsdl并在SOAP UI中打开该WSDL时,我们就会<!--Optional-->在每个元素的顶部.我想删除这个选项标记<!--Optional-->标记,因此我尝试使用@XMLElement(required = true)方法,这样当我在SOAP UI <!--Optional-->中打开WSDL时,不会出现强制性元素.
根据我的概念,@ XMLElement(required = true)将minOccurs设置为1,即大于零,因此当我在SOAP UI中打开它时,可选的注释将从WSDL中删除.但不幸的是它没有用,因此我的概念不正确.生成WSDL之后,我可以看到minOccurs仍为0.
请解释在SOAP UI中打开WSDL时如何删除可选标记.
问候,