Web services 将基于spring集成的web服务转换为spring boot时面临的问题
我想将基于Spring集成的web服务转换为Spring引导应用程序 我的应用程序是使用spring集成web服务开发的。 我想把现有的应用程序转换成spring boot。我已经试着找到了很多演示。网上没有演示 在转换时,我面临着这个问题 提交请求后,我的Soap meesage响应如下:Web services 将基于spring集成的web服务转换为spring boot时面临的问题,web-services,soap,spring-boot,spring-integration,Web Services,Soap,Spring Boot,Spring Integration,我想将基于Spring集成的web服务转换为Spring引导应用程序 我的应用程序是使用spring集成web服务开发的。 我想把现有的应用程序转换成spring boot。我已经试着找到了很多演示。网上没有演示 在转换时,我面临着这个问题 提交请求后,我的Soap meesage响应如下: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:He
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring xml:lang="en">No adapter for endpoint [countryGateway]: Is your endpoint annotated with @Endpoint, or does it implement a supported interface like MessageHandler or PayloadEndpoint?</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Spring配置如下所示
Sample-context.xml
<bean id="payloadMapping"
class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
<property name="mappings">
<props>
<prop
key="{http://spring.io/guides/gs-producing-web-service}getCountryRequest">countryGateway</prop>
</props>
</property>
</bean>
<int:channel id="countryRequestChannel"></int:channel>
<int:channel id="countryResponseChannel"></int:channel>
<int:channel id="countryErrorChannel"></int:channel>
<int-ws:inbound-gateway id="countryGateway"
error-channel="countryErrorChannel" request-channel="countryRequestChannel"
reply-channel="countryResponseChannel" />
<int:service-activator input-channel="countryRequestChannel" output-channel="countryResponseChannel" method="hello" ref="sampleActivator"></int:service-activator>
<bean id="sampleActivator" class="com.sample.country.SampleValidate"></bean>
我看不到您在任何地方引用
示例context.xml
尝试添加
@ImportResource("Sample-context.ml")
到应用程序
类
编辑
@EnableWs
不添加MessageEndpointAdapter
,只添加MethodEndpointAdapter
这很有效
@EnableWs
@Configuration
@ImportResource("Sample-context.xml")
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(MessageDispatcherServlet servlet) {
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean
public MessageDispatcherServlet servlet() {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setTransformWsdlLocations(true);
return servlet;
}
@Bean
public MessageEndpointAdapter adapter() {
return new MessageEndpointAdapter();
}
@Bean(name = "countries")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("CountriesPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");
wsdl11Definition.setSchema(countriesSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema countriesSchema() {
return new SimpleXsdSchema(new ClassPathResource("countries.xsd"));
}
}
添加后也会出现相同的错误。问题未得到解决
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.EnableWs;
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.XsdSchema;
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean(name = "countries")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("CountriesPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");
wsdl11Definition.setSchema(countriesSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema countriesSchema() {
return new SimpleXsdSchema(new ClassPathResource("countries.xsd"));
}
}
@ImportResource("Sample-context.ml")
@EnableWs
@Configuration
@ImportResource("Sample-context.xml")
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(MessageDispatcherServlet servlet) {
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean
public MessageDispatcherServlet servlet() {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setTransformWsdlLocations(true);
return servlet;
}
@Bean
public MessageEndpointAdapter adapter() {
return new MessageEndpointAdapter();
}
@Bean(name = "countries")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("CountriesPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");
wsdl11Definition.setSchema(countriesSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema countriesSchema() {
return new SimpleXsdSchema(new ClassPathResource("countries.xsd"));
}
}