Я пытаюсь использовать SchemaCollection
в своей конфигурации веб-службы. Но когда я добавил код для этого, я получаю эту ошибку:
Причина: java.lang.IllegalArgumentException: schemaElement не должен быть нулевым! Вы запускали afterPropertiesSet () или регистрировали это как бин Spring?
Что означает эта ошибка? Глядя на Spring code , что-то связано с schemaElement
на XSD, но я не могу сказать, что.
Без коллекции schema все отлично работает.
Полная ошибка:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pedidos' defined in class path resource [br/com/company/rdt/config/WebServiceConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: schemaElement must not be null! Did you run afterPropertiesSet() or register this as a Spring bean?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.17.RELEASE.jar:1.5.17.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.17.RELEASE.jar:1.5.17.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.17.RELEASE.jar:1.5.17.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.17.RELEASE.jar:1.5.17.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.17.RELEASE.jar:1.5.17.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.17.RELEASE.jar:1.5.17.RELEASE]
at br.com.company.rdt.IntegracaoRmsApplication.main(IntegracaoRmsApplication.java:12) [classes/:na]
Caused by: java.lang.IllegalArgumentException: schemaElement must not be null! Did you run afterPropertiesSet() or register this as a Spring bean?
at org.springframework.util.Assert.notNull(Assert.java:134) ~[spring-core-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.xml.xsd.SimpleXsdSchema.getTargetNamespace(SimpleXsdSchema.java:95) ~[spring-xml-2.4.3.RELEASE.jar:na]
at org.springframework.ws.wsdl.wsdl11.provider.InliningXsdSchemaTypesProvider.addTypes(InliningXsdSchemaTypesProvider.java:99) ~[spring-ws-core-2.4.3.RELEASE.jar:na]
at org.springframework.ws.wsdl.wsdl11.ProviderBasedWsdl4jDefinition.afterPropertiesSet(ProviderBasedWsdl4jDefinition.java:234) ~[spring-ws-core-2.4.3.RELEASE.jar:na]
at org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition.afterPropertiesSet(DefaultWsdl11Definition.java:183) ~[spring-ws-core-2.4.3.RELEASE.jar:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627) ~[spring-beans-4.3.20.RELEASE.jar:4.3.20.RELEASE]
... 16 common frames omitted
Объявление бина:
@Bean(name = "orders")
public DefaultWsdl11Definition defaultWsdl11Definition() {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("PedidosPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://www.oracle.com/retail/igsla/integration/services/XYZFullPublishingService/v1");
wsdl11Definition.setSchemaCollection(schemaCollection());
wsdl11Definition.setRequestSuffix("Desc");
wsdl11Definition.setResponseSuffix("Desc");
return wsdl11Definition;
}
private XsdSchemaCollection schemaCollection() {
return new XsdSchemaCollection() {
public XsdSchema[] getXsdSchemas() {
return new XsdSchema[]{new SimpleXsdSchema(new ClassPathResource("orders.xsd")), new SimpleXsdSchema(new ClassPathResource("po.xsd"))};
}
public XmlValidator createValidator() {
throw new UnsupportedOperationException();
}
};
}
XSDs. Orders.xsd:
<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:po="http://www.oracle.com/retail/integration/base/bo/XYZFullDesc/v1"
targetNamespace="http://www.oracle.com/retail/abcd/integration/services/XYZFullPublishingService/v1"
elementFormDefault="qualified">
<s:import schemaLocation="po.xsd"
namespace="http://www.oracle.com/retail/integration/base/bo/XYZFullDesc/v1" />
<s:element name="publishXYZFullModifyUsingXYZFullDesc">
<s:complexType>
<s:sequence>
<s:element ref="po:XYZFullDesc"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
И po.xsd:
<?xml version="1.0" encoding="utf-16" ?>
<s:schema targetNamespace="http://www.oracle.com/retail/integration/base/bo/XYZFullDesc/v1"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.oracle.com/retail/integration/base/bo/XYZFullDesc/v1"
elementFormDefault="qualified">
<s:element name="XYZFullDesc" type="XYZFullDesc"/>
<s:complexType name="XYZFullDesc">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="order_no" type="s:string"/>
</s:sequence>
</s:complexType>
</s:schema>