4 Replies Latest reply: May 14, 2012 3:52 AM by Rockit8 RSS

    Webservice Stubs

    Rockit8

      Hi

       

      I've working with webservices for a while now and i know that coldfusion generates java classes for a given wsdl and that these classes are in the <coldfusion_install_dir>\stubs\

       

      Inside the stubs directory there is one folder for each referenced webservice...these folders have names like WS-882657457 or WS2071109075.

       

      What is the relation between the WSDL and these folders? Where can I see the association Webservice - Stub Folder?

       

      Regards.

        • 1. Re: Webservice Stubs
          byron1021 Community Member

          Always found these to be very random. You might be able to use jad, a java decompiler, to gain insight to the url embedded on the class files.

          • 2. Re: Webservice Stubs
            Rockit8 Community Member

            It depends, they aren't allways random:

            • If you had the webservice reference via the Coldfusion Administrator and specify a name that is different from the WSDL the java stubs will be inside a folder with the webservice name you specify when adding the reference.
            • If you do a cfinvoke them Coldfusion "auto-adds" the reference and the folder name will be "random".

             

            What i needed was something that based on the Webservice name or WSDL gaves me the path to the stub which is possible to do via the following code:

             

            <cfobject action="CREATE" type="JAVA" class="coldfusion.server.ServiceFactory" name="ServiceFactory">

            <cfdump var="#ServiceFactory.getXMLRPCService().getWebservice("MyTestWS", ServiceFactory.getXMLRPCService().getMappings()).getClass().getProtectionDomain().getCode Source().getLocation().toString()#"/>

             

            Anyone knows how can I "convert" this code from cf to java? I need to do this inside a java CFX tag.

             

            Regards.

            • 3. Re: Webservice Stubs
              BKBK MVP

              Your example deals with Jave objects already. So why not just write the Java code directly from there? Something like

               

              import coldfusion.server.ServiceFactory;

               

              public class MyClass

              {

                  public String testFunction()

                  {

                 

                      try {

                     

                       //declare ServiceFactory variable

                       ServiceFactory serviceFactory;

                     

                       //instantiate ServiceFactory variable

                       serviceFactory = new ServiceFactory();

                     

                       //etc., etc., and off you go

                     

                      }

                      catch (Throwable ex) {

                          ex.printStackTrace();

                      }

                 

                      return someString;

                  }

              }

               

              Having said that, I have a lot of doubt about the strategy you're following. It is still unclear, to me at least, what you wish to achieve. Why would you want to have a handle on the internal ColdFusion processes between the WSDL and the stubs directory? Since you don't say, it sounds like you're just tinkering in the bowels of the machine. Even if you get it working, it will probably lead to more problems than you expect.

              • 4. Re: Webservice Stubs
                Rockit8 Community Member

                Hi

                 

                @BKBK i tried that and a "ClassNotFoundException" or something like that.

                Anyway I think the first aproach with the Cf code, creating the java object will be enough.

                 

                Thanks for the replys.

                Regards.