我遵循了SOAP服务的春季指南。我使用弹簧靴
我生成了罐子。我执行
java -jar target/inventorySpringWar2.jar
应用程序初始化权限。我用curl检查服务
curl --header "content-type: text/xml" -d @catalogrequest.xml http://localhost:8080/ws
我收到消息
{"timestamp":"2018-11-01T19:19:53.403+0000","status":404,"error":"Not Found","message":"No message available","path":"/ws"}
这是endPoint类
@Endpoint
public class InventoryEndPoint {
private static final String NAMESPACE_URI = "http://com.uciext.ws.hw5";
private InventoryRepository inventoryRepository;
private InventoryManagerImpl manager;
@Autowired
public InventoryEndPoint(InventoryRepository inventoryRespository) {
this.inventoryRepository = inventoryRepository;
manager = new InventoryManagerImpl();
}
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "catalog")
@ResponsePayload
public CatalogResponse getCatalog() {
这是WebServiceConfig类
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter{
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
ServletRegistrationBean bean = new ServletRegistrationBean();
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean(name = "catalog")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("CatalogPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://com.uciext.ws.hw5");
wsdl11Definition.setSchema(countriesSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema countriesSchema() {
return new SimpleXsdSchema(new ClassPathResource("catalog.xsd"));
}
}
catalog.xsd具有targetNamespace
targetNamespace="http://com.uciext.ws.hw5"
如何配置这些类?