9 Replies Latest reply on Nov 26, 2014 5:31 PM by Max Ozkin

    SOAP endpoint address

    Max Ozkin Apprentice

      Hi, how to set programmatically the endpoint address of SOAP reference binding?

        • 1. Re: SOAP endpoint address
          Jorge Morales Master

          You can't. There is a JIRA for it. Hopefully will make it into 2.0.0, but it doesn't seem as of now.

          Please, search for JIRA and vote for it. It's something like set endpoints dinamically.

          1 of 1 people found this helpful
          • 2. Re: SOAP endpoint address
            Max Ozkin Apprentice

            That's very unfortunate. So, it seems one solution would be then to implement a native client (say, JaxWS) and use it in my bean instead of reference binding... (in scenario where SY application has to invoke the same WS on few different servers).

            • 3. Re: SOAP endpoint address
              Max Ozkin Apprentice

              I found a workaround for this problem. It uses WS addressing.

               

              1. In WSDL file add " <wsaw:UsingAddressing required="true"/>".

              2. In the Bean set the "To" property on the Exchange:

                   String toStr = "<wsa:To xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">WS_URL</wsa:To>";

                   Element to = XMLHelper.getDocumentFromString(toStr).getDocumentElement();

                   i.getContext().setProperty("{http://www.w3.org/2005/08/addressing}To", to, Scope.EXCHANGE);

              where i is an instance of ReferenceInvocation for the web service.

               

              Switchyard's OutboundHandler.handleMessage() method always checks if Addressing is enabled and if so it reads above property and sets JaxWS endpoint address.

               

              With above solution one can change "WS_URL" address dynamically at run-time...

              • 4. Re: SOAP endpoint address
                Max Ozkin Apprentice

                But to my understanding this approach works only if there is no need to deal with two or more endpoint addresses at the same time.

                If there is one SOAP Reference Binding, then there is one JaxWS Dispatch object (per that binding). And that means that only one endpoint address can be active at the same time. Thus if a Bean has to handle multiple requests to different endpoints concurrently, then it can cause a mess with invoking a request on the right endpoint address (unless some locking is implemented on invoke() method, which makes it inefficient).

                • 5. Re: SOAP endpoint address
                  Max Ozkin Apprentice

                  hello! Can any of the experts have a look at the above suggestion and tell if it has any problems or whether it is ok?

                  It is working for me but wanted to check if there are any hidden drawbacks..

                  Thanks.

                  • 6. Re: SOAP endpoint address
                    AYMAN a Newbie

                    I had a similar requirement , i used camel binding with a spring-ws as the implementation. I would set the Header CamelSpringWebserviceEndpointUri to my dynamic URL.

                     

                    You will need though to install this module when you deploy to JBOSS server.

                    • 7. Re: SOAP endpoint address
                      Max Ozkin Apprentice

                      Thanks. Have you been able to set URL per outgoing message? So that concurrent requests to your service could successfully be dispatched to different endpoints at same time?

                      • 8. Re: SOAP endpoint address
                        AYMAN a Newbie

                        Yes i was able to set the URL per outgoing message. I do set it as a  header property on the exchange and spring-ws will use that instead of the default URL if provided.

                         

                        .setHeader("CamelSpringWebserviceEndpointUri",

                                                simple("${body.getResults()[0].get('RESULT')}"))

                                                .setBody(simple("${body.getResults()[0].get('PAYLOAD')}"))

                                                .to("switchyard://CBInternalWebServicePortType")

                         

                         

                        My Config URI on the switchyard reference

                        spring-ws:http://foo.com/bar?timeout=${td.retail.credit.app.imaging.timeout}

                        1 of 1 people found this helpful
                        • 9. Re: SOAP endpoint address
                          Max Ozkin Apprentice

                          Thanks. I also read somewhere that another alternative could be using Camel URI binding with the camel-http component. The idea is similar: to change the header property "Exchange.HTTP_URI" on the exchange.