5 Replies Latest reply on Oct 6, 2006 12:03 PM by jasals

    CFINVOKE for webservice with OVERLOADED METHODS

    jasals
      I am attempting to use Campaign Monitor's API for adding new opt-in subscribers. I need to use the Subscriber.AddWithCustomFields method ( http://app.campaignmonitor.com/api/api.asmx?WSDL)

      This method does not allow the use of GET or POST methods, so I think CFHTTP is out. Form what I can see it would need to be some form of a CFINVOKE tag.

      I am not able to get this to work. They told me they overload their methods. I am thinking that is represented in the dot notation of the method. They also have a method called Subscriber.Add and Subscriber.Unsubscribe, etc...

      So, any ideas out there??
        • 1. Re: CFINVOKE for webservice with OVERLOADED METHODS
          jasals Level 1
          SADLY, there is little or no clear documentation on how to handle webservices that utilize overloading of methods. Equally missing is any input from the Macromedia/Adobe team in these forums on it. There are many webservices out there that use overloading of methods... this needs to be addressed!

          Things used to be better in here... I miss the days of seeing many responses and Team Macromedia or Team Allaire getting involved in the difficult ones.

          Anyway - in case you are trying to accomplish this or a similar task. Try PHP. It works beautifully, I never thought I'd be the guy saying that in here! After being a huge fan of CF for 10 years, I am touting PHP for this task... though I guess Ben Forta does encourage using the best tool in the shed for the task - just suprised that I would have to use another application language for this.

          PHP, for this task, is very simple and straight forward, there is plenty of documentations and real world code examples to get you going via Google searches. Plus most shared servers running Cold Fusion also support PHP.

          I don't like to mix technologies in a web site, but due to Cold Fusion's apparent inability to handle this, I have had to resort to doing this.

          If you need specifics on how I did it, contact me and I will create a snippet that is sanitized for your use. Also you might want to look up other forum posts by me around Sept-Oct 2006 for other comments and code I tried in CF. Might save you a few failure steps with CF on your way to using the PHP route....
          • 2. Re: CFINVOKE for webservice with OVERLOADED METHODS
            ksmith Level 1
            First, the forums have always been setup as a "users" forum. Answers should come from other users. That person may be a Team Somebody or Adobe employee. But that has never been guaranteed. If you want Adobe support or an immediate answer you may need to open a support incident.

            Your webservice looks like a complicated one that will require some work. CFMX seems unable to directly instantiate it. So you will need to create your own java stubs and access it that way. Please review the following technote.

            Once you have created and compiled your java stubs you can use code like:
            <cfscript>
            locator = createobject("java","com.campaignmonitor.app.api.ApiLocator");
            ws = locator.getapiSoap();
            subs = ws.getSubscribers("whatever your args should be");
            </cfscript>

            I looked at your webserver using the services plugin for CFEclipse, that was recently released. It appears that there is not really a AddWithCustomFields method. Instead, you call the AddSubscriber method with an array of SubscriberCustomFields as the last argument:

            ws.AddSubscriber(ApiKey, ListID, Email, Name, ArrayOfSubscriberCustomFields);

            You may be able to use an array of CFC's as your last argument. There have been a number of articles blogged about using data CFC's as arguments for webservices( CFC article). Otherwise, you will need to work through the java stubs to create the array.
            • 3. Re: CFINVOKE for webservice with OVERLOADED METHODS
              jasals Level 1
              Keith,

              Thanks for your reply. I do fully understand that these are user fourms, I had thought that those members with the title "Team Macromedia" were employees who spent some time on the forums during their day. I am apparently wrong about this (per another users comment). I do appreciate the user forums for what they are, I just noticed a seeming reduction in the number of Team Macromedia/Adobe responses and thought perhaps that since the Adobe buyout that these folks were not as free to spend time in here. I will not watch for this any longer nor expect to see these folks as often - nor assume they are Adobe employees. The reason I sought their response was that I see little clear descriptive documentation that explains the SOAP interface, using CFINVOKE, what overloaded methods are, whether they are supported natively, or any of that. It may be there in a format that is less direct, but I missed it. When I broke down and began trying out the PHP code, I found plenty of descriptive easy to understand explanations of what was needed and how to configure it.

              On to your suggestions:
              Not being a Java developer, the idea of creating my own Java stubs is not a likelihood. I am open to learn new things, but I am a thinking this might not be a "JavaNewbie" type of task. I'd be very happy to be corrected about that!!!! Also, to clarify, I am not the owner of the webservice, I am a consumer. I did not write the WSDL. I am a client of the web service and am trying to accesss it with Cold Fusion.

              Also note that I am running my CF in a shared hosting environment. I don't have direct administrative control of the web server or applciation server. I think for now the PHP route is the path of least resistance. Thank you for your reply!

              By the way - I did find that the method was AddSubscriber as you stated... and did try passing the last parameter as an array to no avail. I have tried many ideas to try to get this to work in CF. This was my first tiem working with outside SOAP based webservice APIs and I have been on a learning curve.

              I was not very willing to drop CF and look at PHP. It wasn't my path of choice, jsut the path that ended up working.

              Thanks again!!!!
              -Jon
              • 4. CFINVOKE for webservice with OVERLOADED METHODS
                ksmith Level 1
                FYI,
                You do not need to really know java to do this. WSDL2java creates all the java files for you. You would need to compile and jar them. That is not really a difficult process. There is a technote and other documentation on creating similar stubs to be used with COM objects. If you step through the technote, the compile and jar creation would be the same as for COM ( COM Stubs technote). The same process is documented within the CFMX Developer's guide.

                I understand that you have moved to a PHP solution, for now. Under CF/Java the last argument in your AddSubscriber method will take an array of javaobjects, structures or CFCs. The individual elements will be a string for the name and another string for its value. A simple array of strings would not be appropriate.
                • 5. Re: CFINVOKE for webservice with OVERLOADED METHODS
                  jasals Level 1
                  I will give that last suggestion another go:

                  "Under CF/Java the last argument in your AddSubscriber method will take an array of javaobjects, structures or CFCs. The individual elements will be a string for the name and another string for its value. A simple array of strings would not be appropriate." and post my code and the results I get.
                  This shoudln't require any jar files, right?

                  Thanks!