Я разработал программу Spring Boot Soap Web Service. Он строит и развертывается без ошибок. Но попытка отправить запрос на эту программу всегда возвращает ошибку, и журналы программ также не указывают на получение каких-либо ссылок на получение любых запросов. PrettyPrint-Override "> "timestamp": "2025-05-26T10:23:07.533+00:00",
"status": 404,
"error": "Not Found",
"path": "/ws/hello.wsdl"
< /code>
Когда тот же запрос проверяется в браузере, он генерирует упомянутую ошибку: < /p>
Whitelabel Error Page
This application has no explicit mapping for /error, so you see this as a fallback.
Mon May 26 15:55:29 IST 2025 There was an unexpected error (type=Not Found, status=404).
Когда проверен запрос http: // localhost: 8080/ws (post):
John Doe
< /code>
Он также генерирует ту же ошибку, что и указано выше. Я не могу проверить проблему, которая вызывает этот сценарий. < /p>
HelloEndpoint.java:
package com.example.soap_web_service;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
@Endpoint
public class HelloEndpoint {
private static final String NAMESPACE_URI = "http://example.com/soap-web-service";
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "GetHelloRequest")
@ResponsePayload
public GetHelloResponse sayHello(@RequestPayload GetHelloRequest request) {
GetHelloResponse response = new GetHelloResponse();
response.setGreeting("Hello, " + request.getName() + "!");
return response;
}
}
< /code>
WebServiceConfig.java:
import org.springframework.context.ApplicationContext;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
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;
@Configuration
@EnableWs
public class WebServiceConfig {
@Bean
public ServletRegistrationBean messageDispatcherServlet(
ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean(name = "hello")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema helloSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("HelloPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://example.com/soap-web-service");
wsdl11Definition.setSchema(helloSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema helloSchema() {
return new SimpleXsdSchema(new ClassPathResource("hello.xsd"));
}
}
< /code>
SoapWebServiceApplication.java:
package com.example.soap_web_service;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SoapWebServiceApplication {
public static void main(String[] args) {
SpringApplication.run(SoapWebServiceApplication.class, args);
}
}
< /code>
hello.wsdl:
< /code>
hello.xsd:
< /code>
pom.xml:
4.0.0
com.example
soap-web-service
1.0.0
org.springframework.boot
spring-boot-starter-parent
3.4.5
17
UTF-8
UTF-8
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-web-services
jakarta.xml.bind
jakarta.xml.bind-api
4.0.0
org.glassfish.jaxb
jaxb-runtime
4.0.1
org.springframework.boot
spring-boot-starter-test
test
wsdl4j
wsdl4j
1.6.3
org.springframework.boot
spring-boot-maven-plugin
org.codehaus.mojo
jaxb2-maven-plugin
3.1.0
xjc
xjc
src/main/resources/hello.xsd
com.example.soap_web_service
${project.build.directory}/generated-sources/jaxb
org.codehaus.mojo
build-helper-maven-plugin
3.6.0
add-source
generate-sources
add-source
${project.build.directory}/generated-sources/jaxb
< /code>
Project structure:
.
├── compose.yaml
├── HELP.md
├── mvnw
├── mvnw.cmd
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── soap_web_service
│ │ │ ├── HelloEndpoint.java
│ │ │ ├── SoapWebServiceApplication.java
│ │ │ └── WebServiceConfig.java
│ │ └── resources
│ │ ├── application.properties
│ │ ├── hello-soapui-project.xml
│ │ ├── hello.wsdl
│ │ ├── hello.xsd
│ │ ├── static
│ │ ├── templates
│ │ └── wsdl
│ │ ├── hello.wsdl
│ │ └── hello.xsd
│ └── test
│ └── java
│ └── com
│ └── example
│ └── soap_web_service
│ └── SoapWebServiceApplicationTests.java
└── target
Подробнее здесь: https://stackoverflow.com/questions/796 ... rvice-fail
Все запросы, сделанные на Spring Boot Soap Web Service. ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Java Service Wrapper во время запуска JAR Application FOM Service Service
Anonymous » » в форуме JAVA - 0 Ответы
- 53 Просмотры
-
Последнее сообщение Anonymous
-