Thursday, 3 May 2012

Creating Adobe CQ bundles that consume web services


You can create an Adobe CQ bundle that consumes data from a third-party web service and then display the data in a web page. For example, assume that you use Adobe CQ to create a web site for a government department that tracks weather information. In this situation, you can create a CQ bundle that retrieves data from a third-party web service and display the data within a form located in a web page. The following illustration shows data being retrieved from a third-party web service and displayed in a JSP.


You can develop an OSGi bundle that contains Java proxy classes that were created by using JAX-WS or AXIS. That is, you can use a tool such as  JAX-WS to generate the Java proxy classes that are based on the WSDL of an external web service. Then you can use these Java proxy classes within your OSGi bundle. The OSGi bundle that is created in this development article contains Java proxy classes that consume operations exposed by the following third-party WSDL:

http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL

To read this article, click this link:

https://helpx.adobe.com/experience-manager/using/creating-cq-bundles-consume-web.html

Note: This article uses JAX-WS to generate the Java proxy classes. You can use Apache CXF. For information, see Creating Adobe CQ bundles using Apache CXF that consume web services.

Note: This article discusses using a WSDL to consume a web service. To learn how to build an AEM application that consumes a Restful web service, see http://scottsdigitalcommunity.blogspot.ca/2013/11/creating-adobe-experience-manager.html.

Adobe Digital Marketing Community


Join the Adobe Digital Marketing Community. Start by clicking this banner

About the Author

I (Scott Macdonald) am a Senior Digital Marketing Community Manager at Adobe Systems with over 16 years in the high tech industry. I am also a programmer with knowledge in Java, JavaScript, C#,C++, HTML, XML and ActionScript. If  you would like to see more CQ or other Adobe Digital Marketing end to end articles like this, then leave a comment and let me know what content you would like to see.

Linked Inhttp://www.linkedin.com/in/scottmacdonald2010
TwitterFollow the Digital Marketing Customer Care team on Twitter @AdobeMktgCare.




22 comments:

  1. Hi Scott,

    I am more interested to know the ways of designing and developing .NET based sites in CQ. I mean, it would be good to know the best ways to author .net based web site in CQ?

    Thanks
    Murali

    ReplyDelete
  2. If you want to interface natively with C#, then your choices are as follows:
    1. Build the interface using Java Native Interface (no cost, but very complicated)
    2. Use a 3rd party tool like JNBridge or Jintegra (probably the happy medium)

    If native access is not required then CQ / .NET interoperability could be done by simply wrapping your calls with SOAP / REST and then exchange JSON or XML.I believe Visual Studio has tooling to help there. If you are trying to get to a database, then of course you could use JDBC from CQ.

    Thanks,
    Scott

    ReplyDelete
  3. Hi
    Does it work for CQ 5.4 ?

    ReplyDelete
  4. I will investigate if this works on CQ 5.4 or earlier versions.

    ReplyDelete
  5. Hi
    I did check it and it seems it works on CQ 5.4. Unfortunately from administration point of view we are quite reluctant to modify sling.properties file so i employed an alternative solution - a bundle fragment that exports all com.sun packages from system bundle.

    ReplyDelete
  6. That is a good alternative - nice!

    ReplyDelete
    Replies
    1. Hi Scott,

      In case of an alternative of creating a bundle fragment, what are the ways to commit and deploy the fragment- I understand the fragment creation will be done in a seperate aem project and the created fragment-jar will be placed under crx-quickstart/install folder.This worked if its one environment or local instance- how do I commit it to codebase- so that i dont have to go to each env -dev,test,stage and prod and place the fragment jar in install folder.

      Delete
  7. Hi,

    I have tried this in cq5.4. i created eclipse project and tested in in local and its working fine. so i created an osgi bundle and installed in cq. i can see the exported class name as com.cdyne.ws.weatherws,version=0.0.0. But when i import that class in jsp page im getting error "org.apache.sling.api.scripting.ScriptEvaluationException: An exception occurred processing JSP page /apps/weatherapp/components/page/weathertemplate/weathertemplate.jsp at line 23" because "com.cdyne.ws.weatherws" package is not accessable in jsp page.

    Any solution?

    ReplyDelete
    Replies
    1. Also i tried some other web services.but i'm getting similar error

      Delete
    2. Hi,

      It is working fine after adding sling.bootdelegation.com.sun=com.sun.* in sling.properties.

      Thank you

      Delete
  8. That is a required step for CQ to use Java proxy classes created from the WSDL. I am glad that it's working for you.

    ReplyDelete
  9. Instead of generating it in local and converting as OSGI, Is there any help to generate java proxy from wsdl in CQ itself dynamically.

    Is it possible?

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. Hi Scott
    I add sling.bootdelegation.com.sun=com.sun.* to sling.properties but still doesn't work. Shows same error.
    I'm running CQ5.5 on Java 1.6
    Any clue what else could it be. ?

    ReplyDelete
  12. I found the problem. there are 2 sling.properties file in my cq5.5
    on at crx-quickstart/conf and one at crx-quickstart/
    Once I modify the latter everything works.

    ReplyDelete
  13. I am glad that you got up and running and fixed the issue. Good job!

    ReplyDelete
  14. Pablo, Thank you! I was having the same problem and you gave me the answer!!

    Thank you again!

    ReplyDelete
  15. I found the problem. there are 2 sling.properties file in my cq5.5
    on at crx-quickstart/conf and one at crx-quickstart/
    Once I modify the latter everything works.

    ReplyDelete
  16. This comment has been removed by a blog administrator.

    ReplyDelete
  17. The information which you have provided is very good and easily understood.

    ReplyDelete
  18. Thank you! very nice, clear and helpul post. keep posting more articles on adobe cq5.

    ReplyDelete