Publishing Static WSDL and related XSD schemas using Spring WS

后端 未结 3 1930
栀梦
栀梦 2021-01-18 08:49

I have one module where I have my XSD schemas, where one schema can reference an other using relative path within schema location:



        
3条回答
  •  梦谈多话
    2021-01-18 09:25

    Below is the Java config for exposing the schema. This worked for me. Please note that the schema name should match the Bean name and method name. This is very key for this to work. So I kept the XSD name and Bean name as "CustomerDetailsSchema" and make sure the constructor for getCustomerDetails also matches the name.

    @Bean(name = "customerDetails")
    public DefaultWsdl11Definition getCustomerDetails(XsdSchema CustomerDetailsSchema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("...");
        wsdl11Definition.setServiceName("...");
        wsdl11Definition.setLocationUri("/webservice");
        wsdl11Definition.setTargetNamespace("...");
        wsdl11Definition.setSchema(CustomerDetailsSchema);
        return wsdl11Definition;
    }
    
    @Bean(name = "CustomerDetailsSchema")
    public XsdSchema CustomerDetailsSchema() {
        return new SimpleXsdSchema(new ClassPathResource("schemas/CustomerDetailsSchema.xsd"));
    }
    

提交回复
热议问题