9 Replies Latest reply on Sep 14, 2007 3:06 AM by richard_opalka

    change in run-time the soap:address location of wsdl.

    amitguz

      Hi, I'm tring to create a j2ee client which will call to webservice.
      Only at run time I know the ip of the machine that runs the web-service.

      Do I need to parse the wsdl file and to replace the string <REPLACE_WITH_ACTUAL_URL> by the real ip ?
      Is there another option? I know when using the stub option (which doesn't implemented in JBOSS) there is an option to change the end point IP address in the stub

      _setProperty(ENDPOINT_ADDRESS_PROPERTY, "http://tulip.imagine-com.local:12124");
      


      Currently my code looks as follow
      URL mappingLocation = this.getClass().getClassLoader
       .getResource("META-INF/jaxrpc-mapping.xml");
      File file = new File("C:/a.wsdl");
      URL url = new URL(file.toURL().toString());
      QName serviceName = new QName("http://com.bbb.aa",
       "aaService");
      ServiceFactoryImpl factory = (ServiceFactoryImpl) ServiceFactory
       .newInstance();
      Service service = (Service) factory.createService(url, mappingLocation,
       null, serviceName, null);
      


        • 1. Re: change in run-time the soap:address location of wsdl.

          Stub._setProperty(ENDPOINT_ADDRESS_PROPERTY, "http://tulip.imagine-com.local:12124") should be working. You might have to cast your Port to Stub though.

          • 2. Re: change in run-time the soap:address location of wsdl.
            thomas.diesler

            Use the JSR-109 client deployment model, with <wsdl-override> in jboss-client.xml.

            There are plenty of examples in the testsuite.

            • 3. Re: change in run-time the soap:address location of wsdl.
              astevens1

              Yes jboss-client.xml works but I have potentially up to a 1000 of endpoints for the same service. And they come and go. And the approach of

              Stub stub = (Stub)port;
              stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, this.TARGET_ENDPOINT_ADDRESS);

              doesn't seem to work. Any other suggestions for the 1.0.0GA?

              • 4. Re: change in run-time the soap:address location of wsdl.
                cliffb53

                You can change the file <_server_>/deploy/jbossws14.sar/META-INF/jboss-service.xml from this:

                <attribute name="WebServiceHost">${jboss.bind.address}</attribute>
                


                to this:
                <attribute name="WebServiceHost">www.example.com</attribute>
                


                And then use http://www.example.com:8080/jbossws/services to get a WSDL file for each of the published services.

                Hope this helps.

                • 5. Re: change in run-time the soap:address location of wsdl.
                  acxsjones

                  Did you ever find a way to do this. I need the ability to change the url at runtime.
                  Examples show using ENDPOINT_ADDRESS_PROPERTY, but it does not work.

                  Any help would be great

                  • 6. Re: change in run-time the soap:address location of wsdl.
                    acxjbertr

                    If you know the address of the machine you need to hit at runtime, why not just hit it and get the WSDL that it has generated (which would have the appropriate substitution for REPLACE_WITH_ACTUAL_URL)?

                    Instead of:

                    File file = new File("C:/a.wsdl");
                    URL url = new URL(file.toURL().toString());


                    You would have something like:
                    URL wsdlLocation = new URL("http://hostname:8080/webServiceName/WebServiceName?wsdl");


                    • 7. Re: change in run-time the soap:address location of wsdl.
                      jason.greene

                       

                      "astevens@avaya.com" wrote:
                      Yes jboss-client.xml works but I have potentially up to a 1000 of endpoints for the same service. And they come and go. And the approach of

                      Stub stub = (Stub)port;
                      stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, this.TARGET_ENDPOINT_ADDRESS);

                      doesn't seem to work. Any other suggestions for the 1.0.0GA?


                      This should work, if it doesn't it is a bug. We actually have an internal client that uses this feature (the jboss portal wsrp), so I am not sure how it could not be working. If you can make a simple test case that proves this and create a jira issue with it attached we can take a look at fixing it.

                      -Jason

                      • 8. Re: change in run-time the soap:address location of wsdl.
                        drblmb

                        I don't understand how to do this. Using JBossWS 2.0.1GA - and still can't figure out how to override the end point address. What Stub?

                        Let's suppose you are running in production, and have a web service running at 1,000 different locations (IP Addresses). You don't want the overhead of having to go pull down the WSDL everytime you get the port, so you statically link with a .WSDL file stored locally. The problem, however, is that the soap:address location is statically defined in the WSDL. So - how does your JBossWS client change the endpoint address (NOT THE WSDL LOCATION) after getting the web service port?

                        Example: I have the same web service running at x.x.x.A and at x.x.x.B. So I get the port, and I want to send the same SOAP Request to both servers - why even get the port twice? Just send it to x.x.x.A (assuming that is where the WSDL is pointing to), and then change the endpoint address to x.x.x.B, and using the same port, call the same method again and it should go to x.x.x.B.

                        This is what we need to do - does anyone know how to do this? And yes, I know that you can override the WSDL location in the constructor - that isn't what I need to do here. I have been working on this for several days without success.

                        Thanks

                        • 9. Re: change in run-time the soap:address location of wsdl.
                          richard_opalka

                          Take a look to addressing JBossWS samples and read WS-Addressing spec. It might help you;-)

                          Cheers,
                          Richard