Spring 在 SOAP Web 服务中无法访问 Boot Actuator 端点
Spring Boot Actuator endpoints unreachable in a SOAP web service
我已经使用 Spring Boot 创建了一个 SOAP Web 服务,基于这个教程:https://spring.io/guides/gs/producing-web-service/#scratch.
网络服务运行良好。但是我无法访问通常嵌入在 Spring 引导应用程序中的执行器端点:/env、/health 等
这是我的应用程序的主要配置 class:
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
public final static Logger logger = Logger.getLogger( WebServiceConfig.class );
@Autowired
private WSProperties wsProperties;
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext( applicationContext );
servlet.setTransformWsdlLocations( true );
String urlMappings = wsProperties.getLocationUri() + "/*";
return new ServletRegistrationBean( servlet, urlMappings );
}
/*
* Wsdl11Definition based on a static existing WSDL file
*/
@Bean(name = "myDomain")
public Wsdl11Definition staticWsdl11Definition( XsdSchema schema ){
logger.info("Loading Wsdl11Definition from existing WSDL file");
SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
wsdl11Definition.setWsdl( new ClassPathResource( wsProperties.getWsdlLocation() ) );
return wsdl11Definition;
}
@Bean
public XsdSchema schema() {
logger.info("Loading XSD schema");
return new SimpleXsdSchema( new ClassPathResource( wsProperties.getSchemaLocation() ) );
}
/*
* Declaration of the custom EsceptionResolver to customize SoapFault elements when some exception is thrown.
*/
@Bean(name = "soapFaultAnnotationExceptionResolver")
public DetailSoapFaultDefinitionExceptionResolver exceptionResolver( ApplicationContext applicationContext ){
DetailSoapFaultDefinitionExceptionResolver exceptionResolver = new DetailSoapFaultDefinitionExceptionResolver();
SoapFaultDefinition soapFaultDefinition = new SoapFaultDefinition();
soapFaultDefinition.setFaultCode( SoapFaultDefinition.SERVER );
exceptionResolver.setDefaultFault( soapFaultDefinition );
return exceptionResolver;
}
/*
* Message source for internationalization.
*/
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:locale/messages");
messageSource.setCacheSeconds(3600); // refresh cache once per hour
return messageSource;
}
}
有什么想法吗?
我的 pom.xml
文件中缺少 spring-boot-starter-actuator
依赖项。
我已经使用 Spring Boot 创建了一个 SOAP Web 服务,基于这个教程:https://spring.io/guides/gs/producing-web-service/#scratch.
网络服务运行良好。但是我无法访问通常嵌入在 Spring 引导应用程序中的执行器端点:/env、/health 等
这是我的应用程序的主要配置 class:
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
public final static Logger logger = Logger.getLogger( WebServiceConfig.class );
@Autowired
private WSProperties wsProperties;
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext( applicationContext );
servlet.setTransformWsdlLocations( true );
String urlMappings = wsProperties.getLocationUri() + "/*";
return new ServletRegistrationBean( servlet, urlMappings );
}
/*
* Wsdl11Definition based on a static existing WSDL file
*/
@Bean(name = "myDomain")
public Wsdl11Definition staticWsdl11Definition( XsdSchema schema ){
logger.info("Loading Wsdl11Definition from existing WSDL file");
SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
wsdl11Definition.setWsdl( new ClassPathResource( wsProperties.getWsdlLocation() ) );
return wsdl11Definition;
}
@Bean
public XsdSchema schema() {
logger.info("Loading XSD schema");
return new SimpleXsdSchema( new ClassPathResource( wsProperties.getSchemaLocation() ) );
}
/*
* Declaration of the custom EsceptionResolver to customize SoapFault elements when some exception is thrown.
*/
@Bean(name = "soapFaultAnnotationExceptionResolver")
public DetailSoapFaultDefinitionExceptionResolver exceptionResolver( ApplicationContext applicationContext ){
DetailSoapFaultDefinitionExceptionResolver exceptionResolver = new DetailSoapFaultDefinitionExceptionResolver();
SoapFaultDefinition soapFaultDefinition = new SoapFaultDefinition();
soapFaultDefinition.setFaultCode( SoapFaultDefinition.SERVER );
exceptionResolver.setDefaultFault( soapFaultDefinition );
return exceptionResolver;
}
/*
* Message source for internationalization.
*/
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("classpath:locale/messages");
messageSource.setCacheSeconds(3600); // refresh cache once per hour
return messageSource;
}
}
有什么想法吗?
我的 pom.xml
文件中缺少 spring-boot-starter-actuator
依赖项。