Spring Boot集成WSDL遭遇EndpointNotFound问题求助
Hey there, let's dig into why you're hitting that EndpointNotFound error after switching to a custom WSDL in your Spring Boot SOAP service. I've worked through similar headaches before, so let's break down the most likely culprits and cross-check against your setup:
1. Verify Endpoint Path & WSDL soap:address Alignment
First things first—make sure the endpoint path your Spring Boot service exposes matches the address defined in your custom WSDL:
- Check your
WebServiceConfigclass: TheServletRegistrationBeanfor the message dispatcher servlet should have aurlMapping(like/ws/*) that aligns with thelocationattribute in your WSDL's<soap:address>tag. For example, if your WSDL specifieshttp://localhost:8080/ws/employee-service, your servlet mapping should cover/ws/*to catch that request. - Double-check the
DefaultWsdl11Definitionbean in your config: ThesetPortTypeNameandsetLocationUrivalues need to match the service and port names in your custom WSDL.
2. Match WSDL Target Namespace to @PayloadRoot Annotations
This is the #1 mistake I see with custom WSDLs:
- Grab the
targetNamespacevalue from your WSDL (look for<definitions targetNamespace="...">). - Compare it to the
namespaceparameter in every@PayloadRootannotation in your endpoint class. They need to be exactly identical—even a single typo, case difference, or missing slash will cause Spring to fail matching requests to your endpoint methods.
Example fix if namespaces don't match:
// Wrong (using tutorial's namespace) @PayloadRoot(namespace = "http://javainuse.com/spring", localPart = "GetEmployeeRequest") // Correct (using your custom WSDL's namespace) @PayloadRoot(namespace = "http://yourdomain.com/employee-service", localPart = "GetEmployeeRequest")
3. Validate Dependencies in pom.xml
Ensure you have the required Spring Web Services dependencies (and no conflicting versions):
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web-services</artifactId> </dependency> <dependency> <groupId>wsdl4j</groupId> <artifactId>wsdl4j</artifactId> </dependency>
Missing wsdl4j or using an outdated spring-boot-starter-web-services version can break WSDL parsing or endpoint registration.
4. Dig Into Your Console Logs
Your logs hold critical clues—look for these key entries:
- Confirm your endpoint class is being registered: Look for lines like
Registered endpoint handler mapping: org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMappingfollowed by your endpoint class name. If this is missing, Spring isn't scanning your endpoint bean. - Check WSDL loading: Look for
Loaded WSDL from classpath: /your-custom.wsdl(or similar). If this doesn't appear, yoursetWsdlLocationinDefaultWsdl11Definitionis pointing to the wrong file path. - When you send a request from SOAPUI, check the request path logged (e.g.,
POST /ws/employee-service). If this path doesn't match your configured endpoint mapping, that's a clear mismatch.
5. Fix SOAPUI Request Endpoint
SOAPUI often auto-populates the request endpoint from the WSDL's <soap:address> tag. If your service is running on a different port, host, or path than what's hardcoded in your WSDL, you'll need to manually update the endpoint in SOAPUI's request editor to match your running service (e.g., http://localhost:8080/ws/employee-service).
6. Check XSD & WSDL Association
If your custom WSDL references an XSD schema:
- Ensure the XSD file is correctly placed in your classpath (e.g.,
src/main/resources). - Verify your
XsdSchemabean inWebServiceConfigpoints to the correct XSD path:@Bean public XsdSchema employeeSchema() { return new SimpleXsdSchema(new ClassPathResource("employee.xsd")); }
A missing or misconfigured XSD can prevent the WSDL from being generated correctly, which breaks endpoint matching.
If you're still stuck, sharing snippets of your WebServiceConfig, the targetNamespace from your WSDL, and a sample @PayloadRoot annotation would help narrow things down further.
内容的提问来源于stack exchange,提问作者Robson Rocha

