I created a SOAP web service server with SpringBoot and I was able to successfully create one endpoint. However, I cannot create multiple endpoints and access them with different URLs. I want to handle the process by URL to access.
The SOAP message received by each endpoint has the same schema. (Namespace and localpart are the same !!!) And I don't want to make the WSDL public.
For example.
userA sends the following SOAP message to the following URL: http://soap.example.com/ws/userA
<S:Envelope>
<SOAP-ENV:Header>
</SOAP-ENV:Header>
<S:Body>
<testsoap:post
xmlns:testsoap="http://soap.example.com/">
<testsoap:message>
I am UserA
</testsoap:message>
</testsoap:post>
</S:Body>
</S:Envelope>
userB sends the following SOAP message to the URL: http://soap.example.com/ws/userB
<S:Envelope>
<SOAP-ENV:Header>
</SOAP-ENV:Header>
<S:Body>
<testsoap:post
xmlns:testsoap="http://soap.example.com/">
<testsoap:message>
I am UserB
</testsoap:message>
</testsoap:post>
</S:Body>
</S:Envelope>
The source code is as follows.
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
@Autowired
CustomConfig customConfig;
@Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean<MessageDispatcherServlet>(servlet, "/ws/*");
}
}
I want to access at http://soap.example.com/ws/userA
@Endpoint
public class SoapRequestEndpoint {
private static final String NAMESPACE_URI = "http://soap.example.com/";
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "post")
@ResponsePayload
public JAXBElement<PostResponse> postForA(MessageContext messageContext) {
// do something for userA
}
}
I want to access at http://soap.example.com/ws/userB
@Endpoint
public class SoapRequestEndpoint {
private static final String NAMESPACE_URI = "http://soap.example.com/";
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "post")
@ResponsePayload
public JAXBElement<PostResponse> postForB(MessageContext messageContext) {
// do something for userB
}
}
Thanks.
Updated on September 24th, 2019
I have worked hard since then, but I still don't understand.
I don't think it's written in the official reference.
Do you have any ideas?
Updated on October 3, 2019
I haven't solved it yet.
If this is the case, it will be difficult to work.
Please help someone.