Axis-2 and Axis-1 compatibility issues

July 12, 2012 / Milan Chandna 7 Comments

  Adobe ColdFusion 10 | ColdFusion | WebServices

 Axis-2 and Axis-1 compatibility issues

 

Problem:

With ColdFusion 10 you can leverage power of Axis-2 WebServices. But you might get into issues if you are mixing Axis-2 with Axis-1. Axis-2 services are incompatible with Axis-1 services in ColdFusion because of the way their WSDL's are formed. Though by design Axis-1 and Axis-2 are compatible but in ColdFusion you might run into issues if you are using ColdFusion complex data types.

 

Since Axis-1 and Axis-2 are incompatible, this means that if you are publishing your WebServices using Axis-2, then they should be consumed using Axis-2 only. Similarly if you are publishing your WebServices using Axis-1 then they should be consumed using Axis-1 only.

 

ColdFusion 10 Solution:

ColdFusion has taken all the measures to support backward compatibility with it's earlier versions. ColdFusion allows you to specify the version of Axis in which WebServices should be published or consumed. ColdFusion has given a control at three levels:

  1. Server level
  2. Application level
  3. Component level

Publishing

  1. Server level: In ColdFusion 10 WebServices administrator page there is a new setting called as wsversion. This setting defines the default version of Axis that will be used to publish the WebServices in ColdFusion if you have not specified it at Application/Component level.

    Default value of this setting is set to '2', which means by default your WebServices will be published using Axis-2. You can anytime change it to '1' if you are facing the problems.

    This will be very handy if you are consuming all your WebServices from ColdFusion 9. In ColdFusion 9 Axis-2 is not supported and hence your WebServices will be consume by Axis-1 only, so that is why if all your WebServices are consumed in ColdFusion 9 then you can set this to default '1' for whole server.
  2. Application level: In Application.cfc you can specify an attribute as this:

    <cfset this.wssettings.version.publish = "2">

    Setting this attribute at Application level will ensure that all WebServices in this Application will be published using this version of Axis if not overridden at component level.
  3. Component level: In you WebService component (mywebservice.cfc) you can specify this attribute as this:

    <cfcomponent wsversion="1">
    Specifying this attribute will ensure that this WebService will be published using Axis-1

Consuming

ColdFusion understands that WebServices could be published from any platform and can be consumed from CF so to make it easy CF automatically detects if the service is published in Axis-2 or Axis-1. If it's published in Axis-2, CF will consume it using Axis-2 unless overridden and same goes for Axis-1 too.

 

You can however override this behavior if you are very sure of the published verison, at two levels:

  1. Application level: In Application.cfc you can specify an attribute as this:

    <cfset this.wssettings.version.consume = "2">
    Setting this attribute at Application level will ensure that all WebServices in this Application will be consumed using this version of Axis if not overridden at component level.
  2. Invoking level: While invoking the WebService you can specify an attribute 'wsversion' to tell CF from which version the Service should be consumed.

    ws=createObject("webservice","http://localhost:8500/mycfc.cfc?wsdl",{wsversion="2"})
    <cfinvoke webservice = "http://localhost:8500/mycfc.cfc?wsdl" method="echo" wsversion="2" returnVariable="foo" >

 

 

I am sure that if you read this post, you will never stuck in Axis-1/Axis-2 compatibility issues.

Specially it is a must for any user who is publishing WebService as in ColdFusion 10 but consuming them in ColdFusion 9 or earlier releases. It's because in CF 10 by default Axis-2 will be used whereas in earlier CF releases only Axis-1 was supported, so you might run into issues if will not take measures.

 

Milan.

my blog


7 comments so far ↓

  • 1 Jim O'Keefe // Jul 19, 2012 at 1:40 PM
    I'm trying to consume a SOAP based webservice from salesforce.com that I've successfully consumed on CF8. I'm now setting it up on a CF10 server as well. It doesn't work on cf10. I'm trying to force it to Axis 1 by doing this:
          <cfset sfdc = createObject("webservice","#salesforce_XMLPath#",{wsversion="1"})/>
          <cfset result = sfdc.login("#salesforce_username#", "#salesforce_password#")/>
    The cf10 webservicelog says this"Using Axis 2 for consuming the service https://login.salesforce.com/services/Soap/c/22.0/0DF70000000056J."; so it doesn't seem like that method of declaring Axis 1 is having any effect.
  • 2 Milan Chandna // Jul 20, 2012 at 12:14 AM
    Try this.

    <cfset sfdc = createObject("webservice","#salesforce_XMLPath#",{wsversion="1",refreshwsdl="true"})/>

    Let me know if this works for you.
  • 3 Jim O'Keefe // Jul 20, 2012 at 9:47 AM
    Milan, that did the trick! Thanks. Can you explain a little why that works? The WSDL file hasn't changed.
  • 4 Milan // Jul 20, 2012 at 10:04 AM
    When you consume a Webservice in ColdFusion, the java class/object for that wsdl is created and stored in "ColdFusion10/cfusion/stubs" directory at client side(consuming side). These classes (we can call it as stubs) are then used further if the same wsdl is used to save time and increase performance.

    Refreshwsdl attribute while consuming forces a Webservice stubs to get refreshed. So earlier your saved stub was using Axis-2, but now on giving refreshwsdl='true' the stub got refreshed and it started using Axis-1 and so it worked.

    Now even if you will remove refreshwsdl attribute, it should work. Removing refreshwsdl is a good idea in production as performance increases little bit.

    But you can always put it if you are modifying or updating your services.
  • 5 Ernest // Nov 11, 2013 at 11:34 AM
    Hi All,

    I need to consume a .NET WCF web services using CF 10. I have looked anywhere in Google and I did not find the correct explanation and CF code. The developer documentation “Consuming web services that ColdFusion does not generate” has nothing to look at it (http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-78b4.html).

    Is there any good link, help, blogs or anything about it? We may need to write a good paper-tutorial about this topic. Even if you try to consume a Java EE web services. Any info about it?

    Thank you
  • 6 Milan Chandna // Nov 12, 2013 at 1:08 AM
    Hi Ernest,

    Consuming WCF web services in CF should be simple as there are no extra steps involved, its just same as consuming usual web services.

    But I have observed people getting stuck in consuming WCF when they use complex data types because there is a difference how Dot Net handles Arrays/Struct and how CF handle them.

    I will advice you to Google around topic of handling complex data types in Dot Net and CF in web services and you might get the solution. Also for debugging purpose try to consume simple data types like String and then try Complex one's.

    Happy coding.

    Thanks,
    Milan.
  • 7 Nena // Feb 28, 2014 at 1:20 PM
    Hi,
    Some of these posts are pretty old but I have a question. I'm an enterprise java eng, and I have been given nothing but a <cfinvoke /> signature and ip address with which to call a coldFusion web service programmatically. My question is: how can i do this? Is there a way to quite simply programmatically construct a message of the <cfinvoke ... /> format and then just send it over an Https connection? would that work? any help/pointers would be appreciated thanks!

Leave a Comment

Leave this field empty:

Blue Mango Theme Design By Mark Aplet

Super Powered by Mango Blog