我正在使用带有SAX Parser的spring.oxm和jaxb2将Java对象编组为xml。
我的marshaller抛出一个org.xml.sax.SAXParseException声明存在以下问题:
发现无效的内容以元素“ ns59:ArtID”开头。之一 {[...],http://www.bipro.net/namespace/gevo“:ArtID,[...]}是预期的。
在我的org.springframework.oxm.jaxb.JAXBMarshaller.graph中,一切似乎都正常,至少就我的理解而言。 该图显示了调试模式下的这些变量: 这是jaxax.xml.transform.result.writer,然后因错误中断并留下如下输出字符串:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns43:getShipmentResponse
xmlns="http://www.bipro.net/namespace/basis"
xmlns:ns2="http://www.bipro.net/namespace/nachrichten"
xmlns:ns3="http://www.bipro.net/namespace/abrechnung"
xmlns:ns4="http://www.bipro.net/namespace/allgemein"
xmlns:ns5="http://www.bipro.net/namespace/schaden-leistung"
xmlns:ns6="http://www.bipro.net/namespace/partner"
xmlns:ns7="http://www.bipro.net/namespace/sachen"
xmlns:ns8="http://www.bipro.net/namespace/versicherung/produktmodell/rechtsschutz"
xmlns:ns9="http://www.bipro.net/namespace/produktmodell"
xmlns:ns10="http://www.bipro.net/namespace/versicherung/produktmodell"
xmlns:ns11="http://www.bipro.net/namespace/kapitalanlage/basis"
xmlns:ns12="http://www.bipro.net/namespace/versicherung/produktmodell/komposit"
xmlns:ns13="http://www.bipro.net/namespace/kapitalanlage/transaktion"
xmlns:ns14="http://www.bipro.net/namespace/provision"
xmlns:ns15="http://www.bipro.net/namespace/beteiligungsverhaeltnis"
xmlns:ns16="http://www.bipro.net/namespace/kapitalanlage"
xmlns:ns17="http://www.bipro.net/namespace/versicherung/produktmodell/kraftfahrt"
xmlns:ns18="http://www.bipro.net/namespace/fragen"
xmlns:ns19="http://www.bipro.net/namespace/versicherung/produktmodell/kranken"
xmlns:ns20="http://www.bipro.net/namespace/vertrag"
xmlns:ns21="http://www.bipro.net/namespace/foerderung"
xmlns:ns22="http://www.bipro.net/namespace/versicherung/produktmodell/leben"
xmlns:ns23="http://www.bipro.net/namespace/versicherung/unfall"
xmlns:ns24="http://www.bipro.net/namespace/sepa"
xmlns:ns25="http://www.bipro.net/namespace/versicherung/haftpflicht"
xmlns:ns26="http://www.bipro.net/namespace/schaden-objekte"
xmlns:ns27="http://www.bipro.net/namespace/schaden-details"
xmlns:ns28="http://www.bipro.net/namespace/versicherung/sach"
xmlns:ns29="http://www.bipro.net/namespace/fahrzeug"
xmlns:ns30="http://www.bipro.net/namespace/gevo"
xmlns:ns32="http://www.bipro.net/namespace/evb"
xmlns:ns33="http://www.bipro.net/namespace/prozesse/foerderdaten"
xmlns:ns34="http://www.bipro.net/namespace/prozesse/partner"
xmlns:ns35="http://www.bipro.net/namespace/prozesse/schaden"
xmlns:ns36="http://www.bipro.net/namespace/prozesse/vertrag"
xmlns:ns37="http://www.bipro.net/namespace/prozesse/versicherung/vertrag/komposit"
xmlns:ns38="http://www.bipro.net/namespace/prozesse/versicherung/vertrag/kraftfahrt"
xmlns:ns39="http://www.bipro.net/namespace/prozesse/versicherung/vertrag/kranken"
xmlns:ns40="http://www.bipro.net/namespace/prozesse/versicherung/vertrag/leben"
xmlns:ns41="http://www.bipro.net/namespace/versicherung/tarifierung"
xmlns:ns42="http://www.bipro.net/namespace/tools/iban"
xmlns:ns43="http://www.bipro.net/namespace/transfer"
xmlns:ns44="http://www.bipro.net/namespace/transfer/abrechnung"
xmlns:ns45="http://www.bipro.net/namespace/transfer/gevo"
xmlns:ns46="http://www.bipro.net/namespace/transfer/inkassostoerfall"
xmlns:ns47="http://www.bipro.net/namespace/transfer/schaden-leistung"
xmlns:ns48="http://www.bipro.net/namespace/transfer/schadenrueckfrage"
xmlns:ns49="http://www.bipro.net/namespace/transfer/sepa"
xmlns:ns50="http://www.bipro.net/namespace/transfer/vertrag"
xmlns:ns51="http://www.bipro.net/namespace/kontext/beruf"
xmlns:ns52="http://www.bipro.net/namespace/kontext/betriebsart"
xmlns:ns53="http://www.bipro.net/namespace/kontext/fahrzeug"
xmlns:ns54="http://www.bipro.net/namespace/kontext/partner"
xmlns:ns55="http://www.bipro.net/namespace/kontext/schaden"
xmlns:ns56="http://www.bipro.net/namespace/kontext/unternehmen"
xmlns:ns57="http://www.bipro.net/namespace/kontext/vertrag"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime"> <ns43:Response>
<ns2:BiPROVersion>2.6.1.0.0</ns2:BiPROVersion>
<ns2:Status>
<ns2:ProzessID>1530635989611</ns2:ProzessID>
<ns2:Zeitstempel>2018-07-03T18:41:12</ns2:Zeitstempel>
<ns2:StatusID>OK</ns2:StatusID>
<ns2:Schwebe>false</ns2:Schwebe>
<ns2:Meldung>
<ns2:ArtID>Hinweis</ns2:ArtID>
<ns2:MeldungID>04000</ns2:MeldungID>
</ns2:Meldung>
</ns2:Status>
<ns43:Lieferung>
<ns43:ID>1530636072667</ns43:ID>
<ns43:Einstellzeitpunkt>2016-12-05T00:00:00</ns43:Einstellzeitpunkt>
<ns43:Kategorie>120000000</ns43:Kategorie>
<ns43:VerfuegbarBis>2019-12-05</ns43:VerfuegbarBis>
<ns43:Transfer xsi:type="ns45:CT_GeVoTransfer" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
有人有什么主意,可以指出正确的方向吗?
Lexicore要求2件事。 1.完整的XSD,您可以从https://github.com/JoBieker/soap-bipro/tree/master/securess-bipro/src/main/resources/xsd的开放github存储库中获取。 2.完整的xml,我还没有,因为我想创建它。但是如果我会成功的话,应该会出现这样的情况。这是另一个传世案例,但结构应相同。您可以在此处下载:https://github.com/JoBieker/soap-bipro/blob/master/securess-bipro/src/main/resources/target-xml.xml
最后的词汇问题告诉了我,我完全忘记了我想编组xml。这样就可以了,我的公共github存储库上有代码:https://github.com/JoBieker/soap-bipro 这是控制台提供的完整例外:
2018-07-04 22:19:46.407 错误12986 --- [main] o.s.boot.SpringApplication
:应用程序运行失败org.springframework.beans.factory.UnsatisfiedDependencyException: 创建名称为“ securessBiproApplication”的bean时出错:不满意 通过字段“ marshaller”表达的依赖性;嵌套异常为 org.springframework.beans.factory.BeanCreationException:错误 在类路径中创建名称为“ createJaxb2Marshaller”的bean 资源[de / securess / bipro / config / Jaxb2Config.class]:意外 Bean创建过程中的异常;嵌套异常为 java.lang.IllegalArgumentException:无法解析占位符 值“ $ {context.path}”中的“ context.path”位于 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1350) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:580) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) 〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) 〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]位于 org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]位于 org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]位于 org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]位于 org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]位于 de.securess.bipro.SecuressBiproApplication.main(SecuressBiproApplication.java:43) [classes /:na]原因: org.springframework.beans.factory.BeanCreationException:错误 在类路径中创建名称为“ createJaxb2Marshaller”的bean 资源[de / securess / bipro / config / Jaxb2Config.class]:意外 Bean创建过程中的异常;嵌套异常为 java.lang.IllegalArgumentException:无法解析占位符 值“ $ {context.path}”中的“ context.path”位于 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] ... 18个常见帧 省略的原因:java.lang.IllegalArgumentException:无法 将值“ $ {context.path}”中的占位符“ context.path”解析为 org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) 〜[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) 〜[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) 〜[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) 〜[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda $ processProperties $ 0(PropertySourcesPlaceholderConfigurer.java:175) 〜[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:839) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1086) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:474) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1256) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1105) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) 〜[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE] ... 26个常见帧 省略
最诚挚的问候,jcb
答案 0 :(得分:0)
我知道了。
问题不在于编组,而在于验证。
您已配置JAXB以再次验证指定格式的编组XML:
marshaller.setSchemas(
new ClassPathResource("/xsd/bipro-nachrichten-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-transfer-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-transfer-gevo-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-gevo-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-prozesse-vertrag-2.6.0.xsd"),
new ClassPathResource("/xsd/bipro-basis-2.6.0.xsd")
);
问题出现在ArtID
类型的CT_Geschaeftsvorgang
元素中。这是在Java代码中设置此元素的方式:
JAXBElement<String> value = new JAXBElement<String>(
new QName("http://wwww.bipro.net/namespace/transfer/gevo","ArtID"), String.class, "value"
);
value.setValue("120000000");
CTGeschaeftsvorgang ctVertragsauskunft = new CTVertragsauskunft();
ctVertragsauskunft.setArtID(value);
请注意名称空间URI:http://wwww.bipro.net/namespace/transfer/gevo
,在w
之前有四个transfer
和gevo
。
现在,如果您仔细检查模式bipro-gevo-2.6.0.xsd
,您会发现它具有不同的名称空间:
正确的名称空间是http://www.bipro.net/namespace/gevo
。
Changing http://wwww.bipro.net/namespace/transfer/gevo
至http://www.bipro.net/namespace/gevo
可以解决此问题。