0

Currently, I created a project webservice which I provide 2 webservices endpoint corresponding with 2 versions is MyWebserviceV1 and MyWebserviceV2.
However, I would like to have only one access url and I will forward the request base on targetNamspace.
URL example: localhost:8080/my-project/MyWebservice

I have 2 files wsdl for these versions, each file wsdl I have different targetNamespace:
- MyWebserviceV1: the targetNamespace com.test/myservice-v1.0
- MyWebserviceV2: the targetNamespace com.test/myservice-v2.0

My idea is that: When I receive the SOAP request, base on the targetNamespace (QName from client request) attribute, I will forward to corresponding endpoint.

I intended to use the javax.servlet.Filter for pre-process request but I could not get the target targetNamspace.

How can I get the targetNamespace from SOAP request message, or any configuration available to use for my case.

TuanNN
  • 95
  • 10
  • That's a weird idea. Which WSDL will the client see when calling ``localhost:8080/my-project/MyWebservice?wsdl``? Normally you have a sub path or a sub domain for each version. – Sascha May 22 '19 at 14:48
  • My customer want to have that config. So, I have to use the Servlet to parse the request content and forward to corresponding endpoint base on the Qname from client. Thank you. :) – TuanNN May 23 '19 at 02:17
  • 1
    It's not a good solution because you have to look at the request body for it, but you could implement a servlet filter that [reads and caches the request body](https://stackoverflow.com/questions/34804205/how-can-i-read-request-body-multiple-times-in-spring-handlermethodargumentresol), then searches in it for the QName and lastly [forwards the request](https://stackoverflow.com/questions/2725102/how-to-use-a-servlet-filter-in-java-to-change-an-incoming-servlet-request-url) accordingly. – Sascha May 23 '19 at 08:36
  • I know it is a not good but I have to do that. Thank you for your suggestion. – TuanNN May 23 '19 at 08:53
  • Could you provide some more information? From what you have provided here, this sounds... stupid. I suspect that there are differences in requests and/or responses of the two serviceoperations. Then you won't be able to activate schema validation, as sometimes you will get one type of response and sometimes you will get the other. The consumer of the serviceoperation should be able to tell, if they want to hit one service or the other based on the qname he provides. Why not just configure it to hit the correct endpoint? He wants you to badly bend your solution, so he can be lazy? – Steen May 24 '19 at 07:55
  • The customer's idea is that: User just access the url: localhost:8080/my-project/MyWebservice. Base on the Qname in the request body, In the backend I have to navigate to the version1/version2. – TuanNN May 24 '19 at 08:12
  • If it is truly two different versions of the very same serviceoperation, and you would like them to have the same endpoint, and thus be "backwards compatible" with older versions, for consumers that have not yet updated their code, you may want to look into Blueprint webservices. Then you decouple consumer and provider without the forwarding. – Steen May 24 '19 at 09:51

0 Answers0