5,781,349 members and growing! (59 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Cross Platform » General     Intermediate License: The Code Project Open License (CPOL)

Using C#, Java Webservices and JMS together

By Armoghan Asif, farooqmian

Bridging the gap between Java and C#, JMS specific message have been send to C# client using web services.
C#, Java, .NET 1.1, WinXP, Windows, .NETVisual Studio, VS.NET2003, Architect, Dev

Posted: 13 Jan 2005
Updated: 31 Mar 2006
Views: 57,008
Bookmarked: 37 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
8 votes for this Article.
Popularity: 3.40 Rating: 3.76 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
1 vote, 12.5%
3
3 votes, 37.5%
4
4 votes, 50.0%
5

Introduction

There is no doubt that .NET is much advanced than SWING, So if you need to make a Desktop application. Best Choice is .NET. Java has some advantages in different areas on server side, one of them is JMS. (Many people will not agree). I have tried to use the power of .NET as a client and integrated Java Webserices asynchronously with it, More over I have used JMS on webservices side to send messages to .NET client. Its just the beginning of a small framework which can be extended to make a full-fledged .NET, JMS interaction framework

Background

I had a SWING client/JMS application in java. My other application was in .NET, which also needed to receive messages from the JMS.  

Technologies Used

  1. Asynchronous DOTNET Web services
  2.  DOTNET Delegates
  3. Java Webservices - AXIS 
  4. Java Messaging Service (JMS)
  5. HTTPConnectionFactory

How to run the application?

The Java web service is made using JBuilderX and is tested on JBoss 3.x. To run the application you need to run in the applications in the following sequence

  1. Java Web service.

    Open the project in JbuilderX and run the server with the configuration "Start Web Services Server"
  2. .NET Client

    Update the Web Reference
    Run the application using Visual Studio .NET 2003
  3. Java JMS message publisher class. JMSChatPublisher

    Open the project in JbuilderX and run the application with the configuration "Send messages via JMSPublisher"

    In the console window, write messages and press enter. The messages will go through the webservice and will be shown in the textBox in .NET application. Above also shown the image of what is described.

Architecture Diagram

Using the code

Java side code

NOTE: The code is not optimized and no design patterns are included in it.

The following code is written in ReceiverWebService which creates the JMSChatSubscriber and calls the getSynchronousMessage and waits for a response from the function.  

   public String getJMSChatPublisher() {

    JMSChatSubscriber jmsChatSubscriber = null;
    jmsChatSubscriber = new JMSChatSubscriber();

    return jmsChatSubscriber.getSynchronousMessage();

  }

.NET side code

Client calls the webservice asynchronously using  RegisterJMS and the response is received in the callback ServiceCallback. After the message is received using EndgetJMSChatPublisher. It again calls the RegisterJMS to wait for the next message

    
public void RegisterJMS(NotifyMessage function)
{    
    em = new ReceiverWebServiceService ();
    AsyncCallback cb = new AsyncCallback(ServiceCallback);
    IAsyncResult ar = em.BegingetJMSChatPublisher(cb,em);
    this.callFunction = function;
}
public void ServiceCallback(IAsyncResult ar)
{
    string str = em.EndgetJMSChatPublisher(ar);
    callFunction(str);
    RegisterJMS(callFunction);        
}
            

Conclusion

I have not implemented or showed the following cases, as they are pretty straight forward.
  1. .NET application as a sender -  Create a web method, which receives the message and send it to JMS Topic
  2. Java Receiver - Create a Java Class and it can wait for the message asynchronously.
    subscriber.setMessageListener(messageListerner);
    connection.start();
    // No need to do this as the message will be received in messageListerner
    
    //subscriber.receive();
    
                        

Points of Interest

This application shows how we can receive messages from JMS to .NET Client, with out using any bridging technology, which is not only expensive but a big overhead.  I am not a very good writer, so I hope everything will be understood by the architecture diagrams and code :)

History

01-14-2005:

  • Original article

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Authors

Armoghan Asif



Occupation: Architect
Location: Pakistan Pakistan

farooqmian



Occupation: Architect
Company: Catalisse
Location: Pakistan Pakistan

Other popular Cross Platform articles:

  • Introduction to Mono - Your first Mono app
    The first in a series of articles about Mono. This article explains how to install Mono and shows how to compile your first Cross Platform application.
  • MONO: an alternative for the .NET framework
    This article presents possibilities for development of .NET applications running on operating systems other than Windows, using the MONO platform. Advantages and challenges will be presented. Also presented are some common issues encountered while developing applications using the .NET technology.
  • Embed ActiveX controls inside Java GUI
    With this your Java projects can take advantage of ActiveX controls and Office documents such as spreadsheets, charts, calendars, word processors, specialized graphics, and many more.
  • Introduction to Mono - ASP.NET with XSP and Apache
    The second article in a series of articles about Mono. This article explains how to host and serve ASP.NET Web Applications and Web Services on Linux using XSP and Apache with the help of Mono.
  • Phalanger, PHP for .NET: Introduction for .NET developers
    Phalanger is a PHP language compiler for the .NET Framework which introduces PHP as a first-class .NET citizen.
Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 18 of 18 (Total in Forum: 18) (Refresh)FirstPrevNext
GeneralHow to run the web service in JBuildermembereyadalagha11:33 12 Nov '07  
GeneralInteresting approach...membermichael_rost10:20 11 Jun '07  
NewsTechnology NamememberArmoghan Asif4:11 15 May '07  
Generalhow web service communicate with Alchemi Cross Platform Managermemberpunit singh0:21 10 May '07  
AnswerRe: how web service communicate with Alchemi Cross Platform ManagermemberArmoghan Asif23:20 10 May '07  
Generalcsil project challengememberfawce11:08 12 Jul '06  
GeneralDo things simple!memberVitaly Shelest4:11 22 Jun '06  
GeneralRe: Do things simple!memberArmoghan Asif22:06 23 Jun '06  
GeneralCan not download!memberPham Ngoc Quyen20:26 4 Mar '05  
GeneralRe: Can not download!memberArmoghan Asif23:06 6 Mar '05  
GeneralRe: Can not download!memberPrasad Khandekar21:46 18 Jul '05  
GeneralRe: Can not download!memberArmoghan Asif20:07 20 Jul '05  
GeneralRe: Can not download!memberPrasad Khandekar5:51 21 Jul '05  
GeneralRe: Can not download!memberEyalSch29:43 13 Mar '06  
General...and easy to generalize!memberDavid Dossot5:15 24 Jan '05  
GeneralRe: ...but there is a better approach for JBoss users!memberDavid Dossot2:46 10 Jan '06  
GeneralInteresting approach...memberDavid Dossot22:42 23 Jan '05  
GeneralRe: Interesting approach...memberArmoghan Asif18:28 24 Jan '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 31 Mar 2006
Editor: Smitha Vijayan
Copyright 2005 by Armoghan Asif, farooqmian
Everything else Copyright © CodeProject, 1999-2009
Java | Advertise on the Code Project