Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
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
ApplicationSEClient" and take all otherNew", "Web Service
Client...Browse..." button next to "Project" radio button andclient" and click on "Finish".Properties", "Libraries", "Add
JAR/Folderwebservices-rt.jar" from the "lib" directory of GlassFishOK".Web Service References" node in the project and drag themain" method of "Main.java" of the client project.name" to "Duke".Run". This will build theHello Duke".====[com.sun.xml.ws.assembler.server:request]====<br>
<?xml version="1.0" ?><br>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><br>
<S:Body><br>
<ns2:sayHello xmlns:ns2="http://server/"><br>
<name>Duke</name><br>
</ns2:sayHello><br>
</S:Body><br>
</S:Envelope><br>
============<br>
====[com.sun.xml.ws.assembler.server:response]====<br>
<?xml version="1.0" ?><br>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><br>
<S:Body><br>
<ns2:sayHelloResponse xmlns:ns2="http://server/"><br>
<return>Hello Duke</return><br>
</ns2:sayHelloResponse><br>
</S:Body><br>
</S:Envelope><br>
============Web
Service ReferencesRefresh Client".Confirm Client Refresh" window, select "Also
replace local wsdl file with original WSDLs located at:Yes".Run". This will build theHello Duke".====[com.sun.xml.ws.assembler.server:request]====<br>
<?xml version="1.0" ?><br>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><br>
<S:Header><br>
<To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/SEEndpoint/HelloServiceService</To><br>
<Action xmlns="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</Action><br>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing"><br>
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address><br>
</ReplyTo><br>
...Web
Service ReferencesRefresh Client".Confirm Client Refresh" window, select "Also
replace local wsdl file with original WSDLs located at:Yes".Web Service References"Edit Web Service Attributes" and select "Use
development defaultsSource Packages", "META-INF" andHelloServiceService.xml". The name of this file issc: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 theHello Duke".====[com.sun.xml.ws.assembler.server:request]====<br>
<?xml version="1.0" ?><br>
<S:Envelope<br>
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"<br>
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"<br>
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"<br>
xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"<br>
xmlns:exc14n="http://www.w3.org/2001/10/xml-exc-c14n#"><br>
<S:Header><br>
<To xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5006">http://localhost:8080/SEEndpoint/HelloServiceService</To><br>
<Action xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5005">http://server/HelloService/sayHelloRequest</Action><br>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing" wsu:Id="5004"><br>
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address><br>
</ReplyTo><br>
<MessageID xmlns="http://www.w3.org/2005/08/addressing"
wsu:Id="5003">uuid:bb0e9571-a773-49bb-bad0-20a01d3af9f1</MessageID><br>
<wsse:Security S:mustUnderstand="1"><br>
<wsu:Timestamp
xmlns:ns10="http://www.w3.org/2003/05/soap-envelope" wsu:Id="3"><br>
<wsu:Created>2008-01-23T20:13:28Z</wsu:Created><br>
...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