简体   繁体   中英

cxf spring boot schemalocations configuration

I would like to add to webConfWebService configuration class for my spring boot app a schema(xsd).

With xml configuration is as follows:

<jaxws:endpoint address="/nameService" publishedEndpointUrl="">   
        <jaxws:implementor>
            <bean class=name.pkg.ServiceWSImpl" />
        </jaxws:implementor>
        <jaxws:dataBinding>
            <bean class="org.apache.cxf.xmlbeans.XmlBeansDataBinding" />
        </jaxws:dataBinding>
        <jaxws:serviceFactory>
            <bean class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
                <property name="wrapped" value="false" />
            </bean>
        </jaxws:serviceFactory>
        <jaxws:schemaLocations>
            <jaxws:schemaLocation>classpath:META-INF/xsd/namexsd1.xsd</jaxws:schemaLocation>
            <jaxws:schemaLocation>classpath:META-INF/xsd/namexsd12.xsd</jaxws:schemaLocation>

        </jaxws:schemaLocations>
        <jaxws:inInterceptors>
            <ref bean="authInterceptor" />
        </jaxws:inInterceptors>
        <jaxws:properties>
            <entry key="schema-validation-enabled" value="false" />
        </jaxws:properties>
    </jaxws:endpoint>

and with annotation i started to create my endPOint as follows and i am blocked to how to import the list of schemalocation, i don't know how to do it:

@Configuration
public class WebServiceConfig {

    @Autowired
    private Bus bus;

    @Bean
    public ServletRegistrationBean dispatcherSerlvet() {
        return new ServletRegistrationBean(new CXFServlet(), "/services/*");
    }



    @Bean
    public Endpoint namesServiceEndpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus, new NameServiceImpl());
        endpoint.publish("/Hello");
        endpoint.setSchemaLocations(schemaLocations);//HERE ......
        return endpoint;
    }

It is by adding them in a list as follows:

 List<String> schemaLocations = new ArrayList<String>();
            Resource resource = resourceLoader.getResource(""classpath:/xsd/nameSchema.xsd);
            schemaLocations.add(resource.getFile().getPath());


    endpoint.setSchemaLocations(schemaLocations);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM