Thursday January 31, 2008
TOTD #23: JavaFX Client invoking a Metro endpoint
This TOTD is inspired by Learning JavaFX Script - Part 3. The original article explains how to invoke a Web service from a JavaFX client using NetBeans 5.5.1 and GlassFish v1. Newer version of both NetBeans and GlassFish are available since the article was written. This TOTD (tip of the day) explains how to invoke a Metro endpoint deployed on GlassFish v2 from a JavaFX client - all using NetBeans 6.
Java Class Library" as
shown below:
Finish".MetroClientLibrary" as shown
below:
Finish".New",
"Web Service Client...".Browse..." button next to "Project"
radio button and select the deployed Web service from Metro endpoint
project. If the Web service is deployed on a different machine then you
may specify the WSDL URL. Specify the package name "client"
as shown below:
Finish".Build". This generates a JAR file
that will be utilized later. The location of this jar file is shown in
the Output console. In our case, it is C:\workarea\samples\javafx\MetroClientLibrary\dist\MetroClientLibrary.jar.New Project" and entering the values
as shown below:
Next >" and enter the values as shown below:
Finish".Properties",
"Libraries", "Add JAR/Folder" and select the
JAR file created in "MetroClientLibrary" project as shown
below:
OK".metroclient.Main.fx file, replace "// place
your code here" with the following code:import java.lang.*;
import javafx.ui.*;
import client.NewWebServiceService;
import client.NewWebService;
class InputModel {
attribute name: String?;
}
var inputModel = InputModel { };
var nameField = TextField { };
nameField.action = operation() {
inputModel.name = nameField.value;
};
class ButtonClickModel {
attribute result: String;
}
var model = new ButtonClickModel();
Frame {
title: "JavaFX Client -> Metro endpoint"
width: 350
height: 200
content: GridPanel {
rows: 3
vgap: 5
cells:
[SimpleLabel {
text: "Name :
"
},
nameField,
SimpleLabel {
text: "Result
from endpoint : "
},
Label {
text: bind "{model.result}"
},
Button {
text: "Invoke
Web Service!"
action:
operation() {
do {
try {
var service: NewWebServiceService = new NewWebServiceService();
var port: NewWebService = service.getNewWebServicePort();
var name: String = "{nameField.value}";
var result: String = port.sayHello(name);
System.out.println("response: {result}");
model.result = result;
} catch (e:Exception) {
System.out.println("exception: {e}");
}
}
}
}
]
}
visible: true
};MetroClient")
and select "Run Project". The following window is
displayed:
Duke" in the text box and click on "Invoke
Web Service!" button to see the result as shown below:
After following these steps, you have created a JavaFX client that can invoke a Metro endpoint project deployed on GlassFish - all using NetBeans IDE.
Now Metro provides secure, reliable, transactional and .NET 3.0 interoperable Web service. Have you tried/used any of those features in Metro ?
Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Technorati: totdd javafx metro glassfish netbeans webservices
Posted by Arun Gupta in webservices | Comments[14]
|
|
|
|
|
Wednesday January 30, 2008
South Bay Ruby Meetup Trip Report
As mentioned earlier, I presented on "Rails powered by GlassFish & jMaki" at South Bay Ruby Meetup yesterday. The slides are available here.
The demos showed in the talk are listed below:
There were approx 25 attendees with an extremely interactive session. I would love to capture all the Q&A but the audience kept me busy :)
You can read about JRuby-on-GlassFish and NetBeans/Ruby support. GlassFish success stories are described in blogs.sun.com/stories.
Let me know if you are interested in having this talk at your Ruby meetup.
Technorati: conf jruby rubyonrails glassfish netbeans meetup netbeans
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Tuesday January 29, 2008
JRuby-on-Rails deployed on GlassFish - Success Story
There are several reasons you may deploy JRuby-on-Rails application on GlassFish:
Technorati: glassfish netbeans jruby rubyonrails mediacast stories
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
This is 500th blog entry on this blog :)
Here is the tag cloud indicating the major topics covered so far:

And here is a geographic distribution of readers:

Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Monday January 28, 2008
GlassFish at WebGuild Web 2.0 Conference & Expo 2008 - Jan 29

Sun Microsystems is a sponsor of WebGuild's Web 2.0 Conference & Expo and you can meet me at Sun booth in the exhibitor hall. Register for a FREE exhibitor pass here.
Ask me about:
Technorati: conf jmaki jruby netbeans glassfish rubyonrails jruby jersey
Posted by Arun Gupta in web2.0 | Comments[2]
|
|
|
|
|
Sunday January 27, 2008
Frankfurt to San Jose - $54.54 for one minute call
I used my credit card to call home (San Jose, CA) from Frankfurt
Airport during a trip last year. And the calling company charged $54.54
for an approximately one minute call. Here is what I see in my credit
card statement detail:
| Transaction Date | 12/10/2007 |
| Transaction Description | INTL CL* 800-5762118 CA |
| Called From | GERMANY GE Number: 0114901113 |
| Called To | LOS GATOS CA Number: xxx-xxx-xxxx |
| Time of Call: 00:22 | Duration: 00:05 |
| Charge: | $54.54 |
| Merchant Address | INTERNATIONAL CALLING 511 E SAN YSIDRO BLVD SUITE 1770 SAN YSIDRO CA 92173 USA |
Posted by Arun Gupta in General | Comments[3]
|
|
|
|
|
Saturday January 26, 2008
"Rails powered by GlassFish & jMaki" @ South Bay Ruby Meetup - Jan 29, 7pm
![]() |
I'll be speaking on "Rails powered by GlassFish & jMaki" at South Bay Ruby Meetup on Jan 29 (Tuesday) @ 7pm. Read more details here. |
You'll learn:
Thanks to Bala for providing an opportunity to talk about our efforts! Let's keep an interactive dialog and learn from each other :)
Technorati: conf jruby rubyonrails glassfish netbeans meetup
Posted by Arun Gupta in web2.0 | Comments[1]
|
|
|
|
|
Friday January 25, 2008
TOTD #22: Java SE client for a Metro endpoint
Metro is the Web services stack in GlassFish. It is your one-stop shop from a simple Hello World to Secure, Reliable, Transactional and .NET 3.0 interoperable endpoint. Metro Tooling is provided by NetBeans and other options are explained here.
Screencast #ws7 describes how a Metro endpoint can be easily created and deployed on GlassFish and invoked from a Web client using NetBeans IDE. This TOTD (as requested here and here) describes how a Secure and Reliable Metro endpoint can be invoked using a Java SE client.
Here is my environment:
Let's get started.
Java/Java
Application. Name the project as "SEClient" and take all other
defaults.New", "Web Service
Client...".Browse..." button next to "Project" radio button and
select the deployed Web service endpoint.client" and click on "Finish".Properties", "Libraries", "Add
JAR/Folder" and add "webservices-rt.jar" from the "lib" directory of GlassFish
installation. Click on "OK".Web Service References" node in the project and drag the
leaf node in the "main" method of "Main.java" of the client project.name" to "Duke".Run". This will build the
project, invoke the endpoint and show the results in Output window as
"Hello Duke".====[com.sun.xml.ws.assembler.server:request]====
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:sayHello xmlns:ns2="http://server/">
<name>Duke</name>
</ns2:sayHello>
</S:Body>
</S:Envelope>
============
====[com.sun.xml.ws.assembler.server:response]====
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:sayHelloResponse xmlns:ns2="http://server/">
<return>Hello Duke</return>
</ns2:sayHelloResponse>
</S:Body>
</S:Envelope>
============Web
Service References", right-click and select "Refresh Client".Confirm Client Refresh" window, select "Also
replace local wsdl file with original WSDLs located at:" checkbox
and click on "Yes".Run". This will build the
project, invoke the endpoint and show the results in Output window as
"Hello Duke".====[com.sun.xml.ws.assembler.server:request]====
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/SEEndpoint/HelloServiceService</To>
<Action xmlns="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</Action>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>
...Web
Service References", right-click and select "Refresh Client".Confirm Client Refresh" window, select "Also
replace local wsdl file with original WSDLs located at:" checkbox
and click on "Yes".Web Service References"
node, select "Edit Web Service Attributes" and select "Use
development defaults". This will ensure that client and endpoint
security credentials match.Source Packages", "META-INF" and
open "HelloServiceService.xml". The name of this file is
derived from the service name at the endpoint and may be different.
Specify the location of trust store by adding the following attributes
to "sc:KeyStore" element:location="C:\testbed\glassfish\final\glassfish\domains\domain1\config\cacerts.jks"
type="JKS" storepass="changeit"<sc:TrustStore wspp:visibility="private" peeralias="xws-security-server"
location="C:\testbed\glassfish\final\glassfish\domains\domain1\config\cacerts.jks"
type="JKS" storepass="changeit"/>Run". This will build the
project, invoke the endpoint and show the results in Output window as
"Hello Duke".====[com.sun.xml.ws.assembler.server:request]====
<?xml version="1.0" ?>
<S:Envelope
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
xmlns:exc14n="http://www.w3.org/2001/10/xml-exc-c14n#">
<S:Header>
<To xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5006">http://localhost:8080/SEEndpoint/HelloServiceService</To>
<Action xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5005">http://server/HelloService/sayHelloRequest</Action>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5004">
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>
<MessageID xmlns="http://www.w3.org/2005/08/addressing"
wsu:Id="5003">uuid:bb0e9571-a773-49bb-bad0-20a01d3af9f1</MessageID>
<wsse:Security S:mustUnderstand="1">
<wsu:Timestamp
xmlns:ns10="http://www.w3.org/2003/05/soap-envelope" wsu:Id="3">
<wsu:Created>2008-01-23T20:13:28Z</wsu:Created>
...If you are using JDK version prior to Java SE 6 U4, then need to override the JAX-WS and JAXB API as described here. Java SE 6 U4 already includes JAX-WS and JAXB 2.1 APIs which are required for the Metro client to work.
Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Technorati: totd webservices metro glassfish netbeans javase
Posted by Arun Gupta in webservices | Comments[18]
|
|
|
|
|
Thursday January 24, 2008
jMaki and Asynchronous Ajax @ Ajax World, New York 2008
![]() |
The jMaki session at the
upcoming
Ajax World East 2008 is featured on
Web2Journal. Enjoy several jMaki screencasts before the talk :) |
Jean-Francois is also speaking on Asynchronous Ajax for Revolutionary Web Applications - He is a great speaker and interesting topic too!
If you want to speak, the Call For Paper for Ajax World closes tomorrow (Jan 25, 2008).
Technorati: conf jmaki ajaxworld web2journal
Posted by Arun Gupta in web2.0 | Comments[0]
|
|
|
|
| Little Rock National Airport Rocks - Free WiFi
![]()
Little Rock National Airport literally rocks - Free WiFi all through out the terminal :)
Technorati: littlerock airport wifi traveltips
Posted by Arun Gupta in General | Comments[2]
|
|
|
|
| RESTful representation of "sakila" using GlassFish and NetBeans IDE
"sakila" is the sample database shipped with MySQL (pronounced as my ess-kew-ell). In the context of Sun Microsystems announcing the agreement to acquire MySQL, I'd like to dedicate this entry to show how this sample database can be exposed as a RESTful Web service endpoint and deployed on GlassFish using Jersey Tooling Plugin (0.4.1 with Jersey 0.4) in NetBeans IDE.
Lets get started!
sakila".mysqld-nt --user root
--console' in bin directory on Windows or './bin/mysqld_safe'
from MySQL directory on Unix flavors.sakila".
Choose "GlassFish v2" as the "Server:".Services" tab of NetBeans IDE, expand "Drivers" and add
MySQL
Connector/J driver if it does not exist already.
New", "Entity Classes from
Database...". In "Data Source", select "New Data Source..." and specify the
values as shown below:
film" in "Available Tables" and click on "Add >" as shown
below:
Next >".Create Persistence Unit..." and take all the defaults as shown
below:
Create".sakila" as shown below:
Finish".Configuration Files"
and open "persistence.xml". Specify the username and password
by replacing <properties/> with the following fragment:<properties>
<property name="toplink.jdbc.user" value="root"/>
<property name="toplink.jdbc.password" value=""/>
</properties>Tools", "Plugins", "Available Plugins", "RESTful
Web Services" and then click on "Install". This installs the
Jersey Tooling
Plugin in the IDE.New", "RESTful Web Services from
Entity Classes...".Add >>", take all other defaults as shown
below:
Next >", take all defaults and then "Finish".Test RESTful Web Services".
The following web page is presented in the browser:
films" and then on "Test" as shown
below:
Test" button or the URL "http://localhost:8080/sakila/resources/films/"
shows the RESTful representation of the "Film" table. The
default representation shows 10 records from the table where each entry
returns the "id" of the film and a reference to the detailed
entry.http://localhost:8080/sakila/resources/films/?max=40".
Additional fields from the table can be displayed by adding getter methods
to "converter.FilmRefConverter" class such as:@XmlElement
public String getTitle() {
return entity.getTitle();
}

Here are few more ideas for you to explore:
A JRuby-on-Rails application using MySQL is explained here. TOTD #9 explains how JDBC connection pooling in GlassFish can be used for a JRuby-on-Rails application using MySQL.
The key message here is MySQL can be very easily used with GlassFish and NetBeans IDE makes it possible! Once MySQL becomes part of Sun, this integration is going to be much more seamless for the betterment of community.
All the entries on this blog using MySQL can be found here. And last but not the least, Welcome aboard MySQL!
A NetBeans project with all the source code can be downloaded from here. You will still need to setup the database connection and need to make sure the correct version of Jersey plug-in as well :)
Technorati: glassfish netbeans jersey mysql sakila jpa jmaki rubyonrails
Posted by Arun Gupta in webservices | Comments[28]
|
|
|
|
|
Wednesday January 23, 2008
FREE chance to win iPhone - No Purchase Necessary
GlassFish Registration Campaign promises exactly that! Just follow the 4 simple steps:
![]() |
|
The sweepstakes start on Jan 23, 2008 and ends on Mar 23, 2008. I'd love to participate but Official Rules would not let me do that :( There is no need to write a blog entry although it would be nice if you do that. This however does not increase your likelihood of winning the iPhone!
What does GlassFish Registration gives you ? - You no longer have to search for all the latest & greatest information about GlassFish. After you register, the following information is available to you in the admin console:
Just imagine the effect of step 4 in the process above. Although it is not mandatory but it greatly improves your chance of winning. So, spread the word and win an iPhone.
Good luck!
Technorati: glassfish javaee5sdk contest iphone
Posted by Arun Gupta in General | Comments[16]
|
|
|
|
|
Tuesday January 22, 2008
Hold the Date - Feb 29, 2008, GlassFish Day is coming to India
|
|
What is GlassFish and
Why GlassFish ? How community is an important aspect ? How is it different and better than other alternatives ? |
If you would like any (or more) of these questions answered, then the upcoming GlassFish Day in Hyderabad, India will provide answers to all of them. This is our first such event in India and we are excited! There will be presentations and demos highlighting different aspects of GlassFish.
Date: Feb 29, 2008
Venue: Hyderabad International Convention
Center, Hyderabad, India
All you need to do is Register for the Tech Days and then you get to attend GlassFish Day as an extra bonus day. The Tech Days Session also provide a wealth of information ranging from Java SE 6, Java Scripting, Project Metro, Java ME and many others.
Community is an overarching aspect of GlassFish. Let us know if you have been using GlassFish and would like to talk in front of audience. Just leave a comment on this blog to get in touch.
Read about success stories, see how GlassFish is used in your geography and how it has been gaining adoption. You can also subscribe to the weekly highlights.
I'll be there, will you ?
Technorati: glassfish glassfishday suntechdays india hyderabad
Posted by Arun Gupta in webservices | Comments[0]
|
|
|
|
|
Monday January 21, 2008
Are you a GlassFish
community member ? Then consider putting one of the following
buttons on your blog, website, attach as your email signature or
anything you like.
![]() |
![]() |
![]() |
![]() |

Posted by Arun Gupta in General | Comments[0]
|
|
|
|
|
Friday January 18, 2008
Travel Plans for Q1 2008 - Fairfax, Little Rock, Orlando, Hyderabad, New York, Las Vegas
Here are my tentative travel plans for the next 3 months:
| Event | Dates | Location |
| Partner Preso | Jan 23 | Fairfax, Virginia |
| Partner Preso | Jan 24 | Little Rock, Arkansas |
| Rails for All | Feb 8-9 | Orlando, Florida |
| Sun Tech Days | Feb 27-29 | Hyderabad, India |
| Ajax World | Mar 18-20 | New York |
| The Server Side Java Symposium | Mar 26-28 | Las Vegas |
Posted by Arun Gupta in webservices | Comments[1]
|
|
|
|
|
Today's Page Hits: 3774
Total # blog entries: 1002