我创建了一个Spring SOAP Controller,该控制器可以在SOAPUI中成功获取我的请求。不幸的是,虽然主Request对象与属性绑定在一起,但其余的Request对象却没有。
Request对象本身在XSD中定义,然后Request对象中的各个字段由另一个XSD定义。我猜这是XSD生成的Java对象的某种Spring配置或某种名称空间问题。但是我没办法尝试了,已经两天了。
请求XSD生成的Java对象(POM XJC创建):
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Request", propOrder = {
"customerInfo"
})
public class Request {
@XmlElement()
protected CustomerInfoType customerInfo;
@XmlAttribute(name = "schemaVersion")
protected String schemaVersion;
}
我可以将所需的内容放入schemaVersion中,并且在控制器中进行调试时,可以在SOAPUI中看到需要输入的内容。
CustomerInfoType XSD生成的Java对象(POM XJC创建):
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CustomerInfoType", propOrder = {
"accountNumber",
})
public class CustomerInfoType {
protected BigInteger accountNumber;
}
请求位于Request.xsd中,而CustomerInfoType是CommonTypes.xsd
以下是相对的Spring Config:
@Bean(name = "RequestyDefinition")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchemaCollection requestSchemaCollection) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("RequestPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://services.com/");
wsdl11Definition.setSchemaCollection(requestSchemaCollection);
return wsdl11Definition;
}
@Bean
public XsdSchemaCollection requestSchemaCollection(XsdSchema request, XsdSchema commonTypes) {
return new XsdSchemaCollection() {
public XsdSchema[] getXsdSchemas() {
return new XsdSchema[]{request, commonTypes};
}
public XmlValidator createValidator() {
throw new UnsupportedOperationException();
}
};
}
@Bean(name = "request")
public XsdSchema requestSchema()
{
return new SimpleXsdSchema(new ClassPathResource("Request.xsd"));
}
@Bean(name = "commonTypes")
public XsdSchema commonTypesSchema()
{
return new SimpleXsdSchema(new ClassPathResource("CommonTypes.xsd"));
}
我收到一个CustomerInfoType为null的请求,但Request属性为一个值。...