我想为我的spring boot app添加webConfWebService配置类一个架构(xsd)。
使用xml配置如下:
<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>
和注释我开始创建我的endPOint如下,我被阻止如何导入schemalocation列表,我不知道如何做:
@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;
}
答案 0 :(得分:0)
将它们添加到列表中如下:
List<String> schemaLocations = new ArrayList<String>();
Resource resource = resourceLoader.getResource(""classpath:/xsd/nameSchema.xsd);
schemaLocations.add(resource.getFile().getPath());
endpoint.setSchemaLocations(schemaLocations);