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]
|
|
|
|
|
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]
|
|
|
|
|
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]
|
|
|
|
|
Thursday January 17, 2008
Tango Overview - Now Translated in Chinese
"Project Tango: Adding Quality of Service and .NET Interoperability to the Metro Web Services Stack" - The original article, introduced here, provides an introduction to how different Quality-of-Service, such as Security, Reliability and Transactions are enabled in Metro. One of the core benefits of Metro is interoperability with .NET 3.0 and the article describes how that is baked in the Web services stack.
The same article is now available in Chinese at Sun Developer Network China. Thanks to the Globalization Team in China for completing this effort, and Zhen Tao in particular who did the translation!
Metro runtime is available as part of GlassFish v2 UR1 and tooling is available in NetBeans 6.
Let us know if you'll be interested in creating a localized version of this article.
Technorati: metro webservices tango glassfish netbeans china
Posted by Arun Gupta in webservices | Comments[0]
|
|
|
|
|
Friday January 11, 2008
Java SE 6 Update 4 is released - "Good Riddance" with JAX-WS Endorsed
Java SE 6 Update 4 is now released. Download it here.
If you are a Metro user
(either JAX-WS or
WSIT) then this is a milestone release
for you because it includes JAX-WS 2.1 API in the rt.jar. This
means that, as a user, you no longer you need to copy JAX-WS or JAXB API jars in
JAVA_HOME/jre/lib/endorsed as described
here,
here and
here. Hurrah!
After you have downloaded and installed JDK 1.6 U4, java
-version shows:
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
wsgen -version shows:
JAX-WS RI 2.1.1 in JDK 6
wsimport -version shows:
JAX-WS RI 2.1.1 in JDK 6
Additionally, you can also verify by greping for
javax.xml.ws.Endpoint class in JAVA_HOME/jre/lib/rt.jar.
This is a new class introduced in JAX-WS 2.1.
Now after you've installed Java SE U4, you can download
Metro 1.1,
set JAVA_HOME to point to this new Java SE installation and you can
easily import a WSDL as:
wsimport -d temp
http://localhost:8080/MetroWithJavaSE6/HelloService?WSDL
parsing WSDL...
generating code...
compiling code...
If you try to import the same WSDL with an earlier release of Java SE 6, then you'll see the error message:
You are running on JDK6 which comes with JAX-WS 2.0 API,
but this tool requires JAX-WS 2.1 API. Use the endorsed standards override
mechanism (http://java.sun.com/javase/6/docs/technotes/guides/standards/), or
use -Xendorsed option.
We hope this will make your life simpler :)
Metro 1.0.1 is anyway baked in GlassFish v2 UR1. You can override it with Metro 1.1 as described in TOTD #21.
Technorati: webservices metro jax-ws glassfish endorsed javase6 jdk
Posted by Arun Gupta in webservices | Comments[19]
|
|
|
|
|
Thursday January 03, 2008
TOTD #21: Metro 1.1 with GlassFish v2 UR1 and NetBeans 6
Metro 1.1 was released last month. This blog describes how to install Metro 1.1 on GlassFish v2 UR1 (which comes with Metro 1.0.1 baked in) and use it with NetBeans IDE.
ant -f setup.xmlant -f wsit-on-glassfish.xml installServices"
tab and right-clicking on "Servers" node and selecting "Add Server...".
These instructions can also be used to override Metro 1.0 that is baked in GlassFish v2 Final build.
Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Technorati: totd webservices metro glassfish netbeans
Posted by Arun Gupta in webservices | Comments[1]
|
|
|
|
|
Saturday December 22, 2007
Metro 1.0.1 and 1.1 are now available
Metro 1.0.1
(integrated in GlassFish
v2 UR1) ad Metro
1.1 are now released. Metro contain stable releases of JAX-WS
RI and WSIT. Read Vivek's
blog for more details.
Even though Metro 1.1 is a stand-alone release, it can be easily
installed on an existing GlassFish instance (for example override on
v2ur1). A later release of Metro 1.1 will be integrated in GlassFish
v2.1. Metro
Roadmap provides all the details.
Please send us your feedback on users@metro
or Forum.
A pleasant change that happened earlier today was that cross-posting
was enabled between user's list and forum. So all the questions posted
on user's list are cross-posted to Forum and vice versa. This enables
wider audience for your questions and more engineers to respond back :)
Technorati: webservices
metro jax-ws wsit glassfish
v2ur1
Posted by Arun Gupta in webservices | Comments[3]
|
|
|
|
|
Friday December 14, 2007
|
|
I presented on GlassFish and related
technologies (Metro,
JRuby-on-GlassFish
and jMaki) at the Department of Computer Science,
Delhi University last week. The
slides are available
here. The talk was very well attended with approximately 120 students and 4 faculty members. The students were pretty excited and had great a interactive session. |
|
Being an alumni of the school (many years ago ;), it was great seeing the new building of the department, meeting the faculty and interacting with the students. I reached there an hour earlier so that I can mingle with the staff and students and it was a lot of fun.
The department faculty proposed to use GlassFish instead of Tomcat for their next semester assignment. I believe this is a great move as it will allow the students to understand the simplicity and power of a great open-source and Java EE 5 compliant Application server.
I initiated the process of recruiting a Campus Ambassador from Delhi University and this will help establish a better relationship between this University and Sun Microsystems.
Here are the questions and answers that were asked during the session:
Here are couple of more links that provide a comparison between the IDEs:
The detailed differences are highlighted here.
Windows"
menu item and then "Services". Right-click on "Servers",
select "Add Server...", select "GlassFish V2"
in the "Choose Server" dialog box. Click on "Next"
and follow the instructions.The complete album is here:
Technorati: conf glassfish webservices metro ruby jruby jmaki web2.0 delhiuniversity delhi netbeans q&a
Posted by Arun Gupta in webservices | Comments[3]
|
|
|
|
|
Thursday December 13, 2007
Screencast #WS8: Tango with NetBeans 6
David Coldrick recorded a screencast for Australian Developer Days. The demo shows how NetBeans 6 allow Web services to be easily created and deployed on GlassFish.
It is similar to screencast #ws7 but good to see somebody else creating these videos :)
Technorati: screencast glassfish webservices metro tango netbeans
Posted by Arun Gupta in webservices | Comments[0]
|
|
|
|
| GlassFish @ Bangalore, Chennai and Pune - Metro, jMaki & JRuby
I presented on GlassFish and other related technologies (Metro, jMaki and JRuby) in Bangalore, Chennai and Pune last week. The slides used during the preso are here. And here is the list of questions (along with answers) for you:
Is Metro plugin available for NetBeans version < 6.0 ?
Yes, Metro plugin is available for NetBeans 5.5.1. This is clearly explained
in
screencast
#ws4. NetBeans 6.0 is now
released and is the recommended version of the IDE.
jMaki.js is the initialization script (18kb) for jMaki that is
loaded when the web application is loaded. This script provides
multiple features, included but not limited to:The jMaki wrapper is a minimal code that needs to be written anyway to invoke the code anyway so there is no additional overhead there.
Is Comet supported in GlassFish/jMaki?
Yes, read about Comet support in GlassFish
The Grizzly Comet and
Writing a Comet application using GlassFish. Also try a simple sample
that demonstrates how
jMaki and Comet (read the
explanation) work nicely with each other.
Can GlassFish deploy EJB 2.0 apps ?
GlassFish is Java EE 5 compliant which maintains backwards compatibility
with J2EE 1.4 and so EJB 2.0 applications can be deployed.
Do GlassFish support Active and Passive cluster ?
In GlassFish the cluster instances talk to each other for health monitoring
through GMS (of Shoal). The buddy
instances talk to each other for replication of the session state. When a
failure is detected the LoadBalancer can failover the request to any
instance in the cluster. The session in question will be fetched from a
replica to this instance in order to continue the conversational state of
the session. In this sense, we have an active cluster.
GlassFish does not have a concept of a standby or passive cluster which will
take over when an active cluster fails altogether. That is usually
considered a high cost approach for redundancy and not advisable.
Read more discussion
here.
Can we add a Metro Web service wrapper be created around
EJB 2.0 ?
Nope, Metro Web service wrapper can be created around EJB 3.0 only.
How can an application deployed on WebLogic be migrated
to GlassFish ?
Migrate2GlassFish
helps automate the migration of J2EE/Java EE applications to GlassFish.
Can Entity beans be configured only as read-only beans -
caching server for these beans ?
Yes, read about the
characteristics, good practices, how to deploy and refresh read-only
beans.
How can jMaki applications run behind the firewall ?
Add the following Servlet parameters to web.xml:
<context-param>
<param-name>proxyHost</param-name>
<param-value>PROXY_HOST</param-value>
</context-param>
<context-param>
<param-name>proxyPort</param-name>
<param-value>PROXY_PORT</param-value>
</context-param>
This is described in detail at
https://ajax.dev.java.net/xmlhttpproxy.html.
Technorati: conf webservices web2.0 ruby jruby projecmetro glassfish netbeans q&a
Posted by Arun Gupta in webservices | Comments[7]
|
|
|
|
|
Tuesday December 11, 2007
![]() |
A book on GlassFish: "Java
EE 5 Development using GlassFish Application Server" by
David
Heffelfinger, was released last month. The publisher sent a courtesy
copy for review, thank you for that. I read good part of the book on my
several flights in past two weeks. First of all, I'd like to thanks the author, publisher and rest of the team for writing this book. Overall I liked the book because of it's simplicity and a good flow through out the book. This is a great book for first timers! |
Here are some of the points that I'd like to highlight:
Here are some potential improvements:
Send feedback to feedback@packtpub.com, making sure to mention the book title in the subject of your message.
In a nutshell - Great book, must buy for first timers, buy your copy here.
Happy reading!
Technorati: glassfish book eclipse netbeans webservices metro
Posted by Arun Gupta in webservices | Comments[2]
|
|
|
|
|
Saturday December 08, 2007
New Java Web Services Instructor-led Training Courses
New Instructor-led classroom training sessions on Java EE 5 Web Services are now available.
These courses teach how to design, implement, deploy and maintain Web services using Java EE 5 platform. NetBeans 5.5 IDE and Sun Java System Application Server Platform Edition 9.0 (GlassFish v1) are used to perform the lab sessions. If the existing schedule does not meet your request, then click on "Request A Class" button.
Stay tuned, new courses based on GlassFish v2 are being developed and will be released soon. In the meanwhile, enjoy screencast #ws7 that shows how to create, deploy and invoke a Secure and Reliable Web service using NetBeans 6 and GlassFish v2.
View the entire Java Web Services learning path.
Technorati: webservices glassfish training learning course metro netbeans
Posted by Arun Gupta in webservices | Comments[4]
|
|
|
|
|
Wednesday November 28, 2007
Metro, jMaki & JRuby/GlassFish Q&A from a Preso - Toronto & Montreal
I presented on Metro, jMaki and JRuby-on-GlassFish at a partner meeting on Nov 21 in Toronto and Montreal (yeah, both cities in the same day). That makes it 3 cities (the first one being Seattle) total for now!
I've given multiple talks all over the world to different types of audience but this was my first experience in terms of talking for 3 hours in the morning, flying to another city and then repeating the sessions. GlassFish (both v2 and v3), NetBeans IDE and Windows Vista behaved properly through all the demos. And my talks are typically demo intensive so it was fun! I enjoyed the overall experience (talking, demos, flying) :)
As always, the fun part was interaction with the audience and I always learn something new every time. And, in order to share the knowledge with you, here is the consolidated list of questions from both the cities:
Although the jmaki framework will work on these browsers some widgets may not work (such as those that use SVG) depending on the browser.
And now for the Metro session:
And finally for the JRuby-on-GlassFish session:
Feel free to ask any other questions in Metro Forum and jMaki Forum or GlassFish forum or JRuby user list.
Technorati: conf webservices metro jmaki glassfish jrubyonglassfish ruby jruby netbeans web2.0 q&a
Posted by Arun Gupta in webservices | Comments[0]
|
|
|
|
|
Monday November 26, 2007
TOTD #19: How to Add Metro Quality-of-Service to Contract-First Endpoint ?
This TOTD explains how to add Reliability and Security to a Contract-First Endpoint using NetBeans IDE.
In the Contract-First, the contract, i.e. the WSDL, is defined first as
opposed to starting from Java. The Metro programming model starts with a Java
Service Endpoint Interface (SEI) and uses
Web
Service Designer to specify Security, Reliability and Transactions support.
This blog uses the WSDL bundled with the fromwsdl sample of
Metro download and adds
Quality-of-Service attributes to it.
Here are the steps to enable Reliable Messaging to Contract-First endpoint:
Web Service from
WSDL..." as shown below:

Browse..." button next to "Web Service Port:" and
select the appropriate port.Finish" and the Web Services Designer is shown as
shown below:
Undeploy and Deploy"
to deploy the project. Web Services" tree, select the newly added Web
service and right-click on "Test Web Service". The Tester page
is shown in a browser with links to the packaged WSDL file and text boxes
and buttons to invoke the Web service.Reliable Message Delivery".Clean" to clean all the
generated files. Again right-click on the project and then select "Undeploy
and Deploy" to deploy the project again.As described in screencast #ws7, Security can be added to a Contract-First endpoint using the steps listed above.
Please leave suggestions on other TOTD that you'd like to see. A complete archive is available here.
Technorati: totd glassfish webservices netbeans metro wsdl reliability contractfirst
Posted by Arun Gupta in webservices | Comments[13]
|
|
|
|
|
Tuesday November 20, 2007
Metro and jMaki Q&A from a Preso
I presented on Metro and jMaki in a invitation-only gathering on Nov 15. The audience in both the sessions was pretty interactive. Even though the sessions were invitation-only, I'm posting some of the questions asked during the sessions along with their answers.
Jmaki.php and XmlHttpProxy.php.And now for the Metro session:
wsit-on-glassfish.xml script and can
be used to override the jars in an existing
GlassFish v2
installation.Metro team also presented a BoF 2526 on these improvements at JavaOne 2006.
Feel free to ask any other questions in Metro Forum and jMaki Forum.
Technorati: conf webservices jmaki glassfish netbeans web2.0 q&a
Posted by Arun Gupta in webservices | Comments[1]
|
|
|
|
|
Today's Page Hits: 1330
Total # blog entries: 1002