Клиент веб-службы Spring не может запуститься
Я использую весенние веб-сервисы, чтобы использовать некоторые мыльные веб-сервисы. Это работало нормально, пока я не добавил новую упаковку в свой маршаллер, бобы unmarshaller.
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" >
<property name="contextPaths">
<list>
<value>package1</value>
<value>package2</value>
<value>package3</value>
<value>package4</value>
<value>package5</value>
<value>package6</value>
<value>package7</value>
</list>
</property>
</bean>
<bean id="unmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" >
<property name="contextPaths">
<list>
<value>package1</value>
<value>package2</value>
<value>package3</value>
<value>package4</value>
<value>package5</value>
<value>package6</value>
<value>package7</value>
</list>
</property>
</bean>
Когда я добавил package7 и веб-приложение моего приложения запускается (оно запускается на сервере), я получаю следующее исключение. Если я удалю "packaage7", исключение исчезнет.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: can't parse argument number: ''{0}''
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
... 74 more
Caused by: java.lang.IllegalArgumentException: can't parse argument number: ''{0}''
at java.text.MessageFormat.makeFormat(MessageFormat.java:1429) [rt.jar:1.8.0_60]
at java.text.MessageFormat.applyPattern(MessageFormat.java:479) [rt.jar:1.8.0_60]
at java.text.MessageFormat.<init>(MessageFormat.java:362) [rt.jar:1.8.0_60]
at java.text.MessageFormat.format(MessageFormat.java:840) [rt.jar:1.8.0_60]
at com.sun.xml.bind.v2.model.impl.Messages.format(Messages.java:133)
at com.sun.xml.bind.v2.model.impl.TypeInfoSetImpl.add(TypeInfoSetImpl.java:306)
at com.sun.xml.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:121)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.addRegistry(ModelBuilder.java:362)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:332)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:460)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:298)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:141)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1163)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:145)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:236)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_60]
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_60]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:137) [rt.jar:1.8.0_60]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:294) [rt.jar:1.8.0_60]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412) [rt.jar:1.8.0_60]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:375) [rt.jar:1.8.0_60]
at org.springframework.oxm.jaxb.Jaxb2Marshaller.createJaxbContextFromContextPath(Jaxb2Marshaller.java:486)
at org.springframework.oxm.jaxb.Jaxb2Marshaller.getJaxbContext(Jaxb2Marshaller.java:453)
at org.springframework.oxm.jaxb.Jaxb2Marshaller.afterPropertiesSet(Jaxb2Marshaller.java:435)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 81 more
Caused by: java.lang.NumberFormatException: For input string: "''{0}''"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) [rt.jar:1.8.0_60]
at java.lang.Integer.parseInt(Integer.java:569) [rt.jar:1.8.0_60]
at java.lang.Integer.parseInt(Integer.java:615) [rt.jar:1.8.0_60]
at java.text.MessageFormat.makeFormat(MessageFormat.java:1427) [rt.jar:1.8.0_60]
... 108 more
Когда я настраиваю маршаллеры только с "package7", я не получаю трассировку стека, но это не работает для меня, так как мне нужны другие пакеты. Я думаю, что есть конфликт с классами, но я не могу понять, что это такое, и исключение очень помогает
Кто-нибудь знает, что может случиться?
ОБНОВЛЕНИЕ:: Я думаю, что эта проблема связана с тем, что есть некоторые пространства имен, которые совместно используются различными пакетами, но они генерируются в каждом из них. Я подозреваю, на некоторых типах.NET:
private final static QName _AnyType_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "anyType");
private final static QName _AnyURI_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "anyURI");
private final static QName _Base64Binary_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "base64Binary");
private final static QName _Boolean_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "boolean");
private final static QName _Byte_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "byte");
private final static QName _DateTime_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "dateTime");
private final static QName _Decimal_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "decimal");
private final static QName _Double_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "double");
private final static QName _Float_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "float");
private final static QName _Int_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "int");
private final static QName _Long_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "long");
private final static QName _QName_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "QName");
private final static QName _Short_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "short");
private final static QName _String_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "string");
private final static QName _UnsignedByte_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "unsignedByte");
private final static QName _UnsignedInt_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "unsignedInt");
private final static QName _UnsignedLong_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "unsignedLong");
private final static QName _UnsignedShort_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "unsignedShort");
private final static QName _Char_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "char");
private final static QName _Duration_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "duration");
private final static QName _Guid_QNAME = new QName("http://schemas.microsoft.com/2003/10/Serialization/", "guid");
1 ответ
организовать пакет wsimport с помощью мыла:
Мое дело:
UsuariosamPleSampleAPISv1_1.wsdl
UsuariosamPleSampleAPISv1.xsd
UsuariosamPleSampleAPISv1_1.xsd
UsuariosamPleSampleAPISv1_1_2.xsd
UsuariosamPleSampleAPISv1_1_2_3.xsd
UsuariosamPleSampleAPISv1_1_2_3_4.xsd
UsuariosamPleSampleAPISv1_1_2_3_4_5.xsd
UsuariosamPleSampleAPISv1_1_2_3_4_5_6.xsd
UsuariosamPleSampleAPISv1_1_2_3_4_5_6_7.xsd
UsuariosamPleSampleAPISv1_1_2_3_4_5_6_7_8.xsd
ServicesaMpleAPISv1.xsd
ServicesaMpleAPISv1_1.xsd
ServicesaMpleAPISv1_1.wsdl
ServicesaMpleAPISv1_1_2.xsd
ServicesaMpleAPISv1_1_2_3.xsd
ServicesaMpleAPISv1_1_2_3_4.xsd
ServicesaMpleAPISv1_1_2_3_4_5.xsd
ServicesaMpleAPISv1_1_2_3_4_5_6.xsd
ServicesaMpleAPISv1_1_2_3_4_5_6_7.xsd
ServicesaMpleAPISv1_1_2_3_4_5_6_7_8.xsd
¬¬ ¬¬ ¬¬
@Configuration
public class ClientsConfiguration extends WsConfigurerAdapter {
@Bean(name = "marshallerpackage1")
public Jaxb2Marshaller marshallerpackage1() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
String[] paquetesBase = new String[] { "package1" };
// error can't parse argument number: ''{0}'' --- new String[] { "package1","package2" };
marshaller.setPackagesToScan(paquetesBase);
return marshaller;
}
@Bean(name = "templatepackage1")
public WebServiceTemplate webServiceTemplatepackage1() {
WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
webServiceTemplate.setMarshaller(marshallerpackage1());
webServiceTemplate.setUnmarshaller(marshallerpackage1());
return webServiceTemplate;
}
@Bean(name = "marshallerpackage2")
public Jaxb2Marshaller marshallerBpackage2() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
String[] paquetesBase = new String[] { "package2" };
marshaller.setPackagesToScan(paquetesBase);
return marshaller;
}
@Bean(name = "templatepackage2")
public WebServiceTemplate webServiceTemplatepackage2() {
WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
webServiceTemplate.setMarshaller(marshallerBpackage2());
webServiceTemplate.setUnmarshaller(marshallerBpackage2());
return webServiceTemplate;
}
}
сторона клиента:
@Service
public class wsClientServiceWs extends WebServiceGatewaySupport {
@Autowired
@Qualifier("marshallerpackage1")
private Jaxb2Marshaller marshallerpackage1;
@Autowired
@Qualifier("templatepackage1")
WebServiceTemplate templatepackage1;
@Autowired
@Qualifier("marshallerpackage2")
private Jaxb2Marshaller marshallerpackage2;
@Autowired
@Qualifier("templatepackage2")
WebServiceTemplate templatepackage2;
try {
templatepackage1.setDefaultUri("http://localhost:8080/wsdl1");
response1 = templatepackage1.marshalSendAndReceive(rq, "soapaction1"));
} catch (Exception e) {
log.error("error Ws soap {}", e.getMessage());
}
try {
templatepackage2.setDefaultUri("http://localhost:8080/wsdl1");
response2 = templatepackage2.marshalSendAndReceive(rq, "soapaction2"));
} catch (Exception e) {
log.error("error Ws soap {}", e.getMessage());
}