WS-Policy and the rest

Fabian's Blog on WS-Policy and the rest
Monday Apr 21, 2008

Metro Hands-on Lab at JavaOne 2008 completely booked

I am being told that the hands-on lab for Metro at JavaOne 2008 is already completely booked. That is certainly a motivator for us to make sure you get the most out of this lab. Hope to see you there, and if you did not get in, try to stop by at the venue, there usually are some no-shows and I believe they will let in people from a waiting queue instead.

Tags: Web Services, Metro, JavaOne


JavaOne 2008

Thursday Apr 17, 2008

Metro Hands-on Lab at JavaOne 2008

Carol McDonald, Martin Grebac and me have developed a hands-on lab for Metro at JavaOne 2008. At the hands-on lab you bring your own laptop and can try out Metro in practice. We have a script with screenshots etc. that you can work through to familiarize yourself with Metro. Carol and I will talk you through the lab. There will be proctors who can help should you have any questions or difficulties. We hope to see you there. I am sure it will be worth your while, the lab involves kittens! (No animals are going to be harmed nor were they harmed when developing the lab and writing this blog.) You can find out more about the lab here: https://www28.cplan.com/cc191/session_details.jsp?isid=296941&ilocation_id=191-1&ilanguage=english

The title of the lab is "Metro: Try Out Simple and Interoperable Web Services". Session ID is 3410. The lab takes place on Tuesday, 10:50 - 12:50. I don't know exactly what room it will be, please check the JavaOne program once you have registered. Here is the complete abstract:

Metro is a high-performance, extensible, easy-to-use web service stack. You can use it for every type of web service, from simple to reliable, secured, and transacted web services that interoperate with .NET services. Metro bundles stable versions of the JAX-WS (Java™ API for XML Web Services) reference implementation and WSIT (Web Services Interoperability Technology).

JAX-WS is a fundamental technology for developing SOAP-based and RESTful Java technology-based web services. WSIT enables secure, reliable interoperability between Java technology-based web services and Microsoft’s Windows Communication Foundation.

This Hands-on Lab starts by developing a simple Metro web service and showing how to enhance this web service with Metro features such as reliability and security. The next part of the lab enables a web service client with Metro security features and has it interoperate with the previously built service. The lab shows the ease of development the NetBeans™ 6.0 release provides for achieving this.

The lab uses the NetBeans 6.0 release to modify and configure both the web service and the client, using Sun’s GlassFish™ project application server as the container. The lab uses WS-Reliability and WS-Security as examples of Metro’s secure, reliable features.

The lab comprises the following sections:

Introduction to Metro
  • Develop and deploy a basic catalog web service to return a list of catalog items
  • Test the web service, using the Tester application provided by the GlassFish project
Metro Reliability
  • Enable reliability on the catalog web service, and examine the messages
  • Develop and deploy a Metro client for the catalog web service, and configure the client for reliable access to the web service
Metro Security
  • Enable security on the catalog web service, and examine the messages
  • Configure the Metro client for the catalog web service (from the previous exercise) for secure access to the secure web service

Prerequisites: some understanding of Servlets, XML, and SOAP

At JavaOne, this lab will be presented in Hall E (Room# 132).

Please bring your laptops to this lab as there no machines provided in this room.

System requirements:
  • Supported OS: Windows 2000/XP, Solaris 10/11, Linux
  • Memory requirement: 768MB minimum, 1GB recommended
  • Disk space requirement: 300 MB

Software requirements:

Also please make sure to install the following software prior to coming to this lab:
  • JDK 5.0 or 6
  • NetBeans 6.0.1 with Web & Java EE pack
  • GlassFish V2 UR1
Tags: Web Services, Metro, JavaOne
JavaOne 2008

Thursday Feb 14, 2008

Non-standard WSIT configuration file locations for Metro

Rickard Lundin recently asked this question: "I need to be able [at] "runtime" to choose wsit config file. One way would be to have multiple "WEB-INF/..xml" and add exactly one of them to the jvm classpath."

There are at least two ways to approach that question. The approach we designed the WSIT configuration for is that you know all your services that you are talking to in advance. That is a reasonable assumption since you need to know the structure of the SOAP messages, etc. to talk to a web service anyway. If you already know the service you are going to talk to, you can do the WSIT configuration before deployment. So the first approach boils down to:

Configuring multiple WSIT web services or clients at once

Creating and configuring multiple web services has been designed into WSIT from the beginning. The WSIT tutorial has an extensive example how to configure one web service without the help of NetBeans. The important aspect of this example is that it uses a configuration file named wsit-fromjava.server.AddNumbersImpl.xml. The configuration file is named after the web service implementation class. That makes it very easy to configure multiple web services. Simply add a configuration file for each service.

The web service client is only slightly more complex to configure. A client has no notion of an implementation class. Thus it always searches for the configuration file wsit-client.xml on the class path. So what do you do when you have multiple clients and all pick up the same configuration file? The solution is to simply put the configuration for all clients into the same file. NetBeans actually does that for you already and it is easy to take the same approach manually. NetBeans generates a wsit-client.xml that looks like this:

<?xml version="1.0" encoding="UTF-8"?> 
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
              xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
              name="mainclientconfig">
    <import location="EchoService.xml" namespace="http://service.echo.ws.xml.sun.com/"/>
</definitions>

The actual configuration is contained in the file EchoService.xml. That makes it very easy to configure clients for additional web services. Simply add more import statements to the wsit-client.xml.

Now while the above covers most use cases, we ran into a problem with Open ESB. Open ESB builds composite applications, which ultimately means in our case that it bundles web services inside an application inside a composite application. Consequently, looking up our configuration files from the class path did not work anymore because the files were inside a bundle on the class path. So we had to create a proprietary extension to:

Pass configuration file location into WSIT

Note that the following is an unsupported extension to WSIT and the interfaces may change any time without notice. Moreover,  the same mechanisms are used to pass servlet data into JAX-WS and you are likely introducing unpleasant side-effects if using this when running a web service as a servlet.

On the client side, you need to create a client by using the create(URL wsdlDocumentLocation, QName serviceName, WSService.InitParams properties) method on WSService. The method returns a Service object that you can use like any ordinary web service client. The properties parameter takes a Container that you need to implement and set as parameter. This Container, when invoked with getSPI(Class<ResourceLoader> ResourceLoader.class), has to return an implementation of the ResourceLoader interface. Finally, the ResourceLoader will be invoked by the PolicyConfigParser with getResource("wsit-client.xml"). That is the point where your application can return a URL to the file it wants WSIT to read. Your file does not have to be named wsit-client.xml.

The implementation on the web service side is pretty similar. Instead of WSService you need to use one of the two create methods on WSEndpoint to create your service. All the create methods take a Container as parameter. From there on the implementation is similar to the client. The getResource call will of course be invoked with the name of the server-side configuration file WSIT is looking for.

Tags: , , , , , ,

Tuesday Feb 12, 2008

Policy code fully integrated again

As I explained in my last blog entry, we moved the policy core code with support for WS-Policy into a separate workspace on java.net several weeks ago: https://policy.dev.java.net/. Since late January that code has been successfully reintegrated into Metro. It was a very smooth process indeed. I set up a build job to create a policy.jar with Maven 2. Then I removed the policy core code from the Project Tango code base and added the policy.jar to the compile class path. The builds have been working flawlessly ever since. You do not actually notice any difference from the outside because the policy.jar like all other run-time libraries for Metro is repackaged in Metro's webservices-rt.jar.

One final step that is still outstanding and that we will realize with JAX-WS 2.2 remains. Right now Project Tango still contains all policy code that has a dependency on JAX-WS. That code will be moved into JAX-WS 2.2 and out of Project Tango entirely. This will allow us to support e.g. WS-Addressing policy assertions directly from JAX-WS without the addition of Project Tango.

Tags: , , , , , ,

Monday Jan 14, 2008

New workspace for policy

We are currently working on moving the existing policy code out of Project Tango and into a separate workspace. This open source project is hosted as a part of the Metro community within GlassFish on java.net. The new workspace will allow us to do two things:

  • Enable direct support of WS-Policy in JAX-WS. JAX-WS will be able to read and generate e.g. WS-Addressing policy assertions without the addition of the Tango code. Essentially, we are moving up the policy code in the Metro stack from Tango to a base library.
  • Pursue experimental APIs, policy languages, etc. This workspace gives us a sandbox to work on new ideas and concepts.

The web site is already fully operational and the policy base code checked in. We are now working on reintegrating that code into the Metro stack.

Tags: , , , , , ,

Friday Dec 21, 2007

WS-Policy in Metro 1.0.1, 1.1 and GlassFish V2 UR1

There has been quite a flurry of release activities this week. We had Metro 1.0.1 and Metro 1.1. Metro 1.0.1 is included with the freshly released GlassFish V2 UR1. For more details about Metro and the releases, see e.g. Vivek Pandey's blog. Our WS-Policy implementation in the context of Project Tango / Web Services Interoperability Technology is an integral part of the Metro stack.

So what is new in WS-Policy for Metro 1.0.1? We really didn't find any severe bugs we needed to fix, i.e. the WS-Policy implementation has no significant changes over Metro 1.0. The same goes for Metro 1.1. Well, there was one bug fix, issue #654: @Addressing annotation does not generate WS-Addressing policy assertions. In practice, this bug had no real practical repercussions because the addressing implementation would be enabled by the annotation anyway.

The one new and exciting feature is that the Metro 1.1 runtime now supports WS-Policy 1.5! We had very successful tests with our implementation at the W3C interop test rounds in spring already and now we finally have proper support in the product. Marek did virtually all the work implementing that feature and it has worked smoothly ever since. Note that our tooling still generates WS-Policy 1.2 expressions to maintain backwards compatibility.

Tags: , , , , , ,

Get GlassFish V2 UR1

Tuesday Sep 18, 2007

WS-Policy in Metro

After almost two years of work, I am very pleased that our code has been released as part of the Metro Web Services stack yesterday! Jakub, Marek and me were responsible for the WS-Policy implementation in the run-time, Martin for tooling. Our implementation provides support for WS-Policy and WS-PolicyAttachment 1.2. It is an open source implementation and among others is built into GlassFish v2.

Our implementation has been designed to work invisibly in the background. The only time you will notice WS-Policy is when policy expressions are included in the WSDL that JAX-WS is generating at run-time. There are no APIs that you need to bother with, you only write ordinary JAX-WS code. You do not need to compile stubs to make use of our WS-Policy implementation, the configuration is picked up at deploy/run-time. NetBeans is providing extensive support to generate the necessary configuration.

In the mean time, we are of course working full swing on the next version already. We have a nice list of features that we plan on supporting in the future, e.g. support for WS-Policy 1.5, better policy enforcement, easier configuration, etc.

Technorati:

Friday Sep 07, 2007

WS-Policy 1.5 published as a W3C recommendation

A few days ago, WS-Policy 1.5 was published as a standard by the W3C. Check out the press release for the relevant links. Monica Martin and me have been active members of the working group and I have been impressed by Monica's capacity and dedication to creating standards of high quality.

We are actively working on support for WS-Policy 1.5 in Project Tango. You can already see our work in action on our interop test site.

Technorati:

Monday Jun 18, 2007

WSIT with a Java SE endpoint

The JAX-WS RI is supporting an Endpoint API that allows you to implement a web service just in plain Java without the need for a Servlet or EJB container. While we don't explicitly test WSIT with this API, it is still working just fine with it. You just need to take into account a few caveats.

Here is some sample web service code. It does not differ in any way from any other JAX-WS web service:

import javax.jws.WebService;

@WebService
public class MyService {

public String hello(final String text) {
return text;
}

}

Since you don't have a container, you will need to write a little bit of code to start a server that can host the web service. This code is ripped right off the Endpoint API documentation:

import javax.xml.ws.Endpoint;

public class Main {

private static final int PORT = 58888;

public static void main(String[] args) {
Endpoint endpoint = Endpoint.create(new MyService());
endpoint.publish("http://localhost:" + PORT + "/");
}
}

You will still need to generate the portable artifacts of your web service before you run it. See the JAX-WS RI User Guide for details.

So far all we have is an ordinary JAX-WS web service. If you are running Java 6, please remember that you need to put the API library into an endorsed directory, otherwise the JAX-WS 2.0 APIs included in Java 6 will override the JAX-WS 2.1 APIs that we require. Put webservices-api.jar into an endorsed directory if you are running Java 6. At runtime you will need webservices-rt.jar and webservices-extra.jar on the classpath and to generate the portable artifacts you need webservices-tools.jar.

So, this was still all plain JAX-WS. All that you need to do to unleash WSIT is provide a configuration file and put it into the META-INF directory of your JAR (or if you have not jared up your code yet, put it in a META-INF directory on your classpath.) Writing a correct configuration file manually is an unpleasant task. I strongly recommend that you use NetBeans to generate one for you and then copy it into your project. The WSIT tutorial has extensive documentation on how to generate a configuration file.

Technorati:

Tuesday May 29, 2007

Public WS-Policy Test Site

The W3C Web Services Policy Working Group ran an interop event last week in Ottawa. We put up a web site for all the policy interop scenarios that we are supporting. All the functionality is built on the open source code of Project Tango / WSIT. The only significant difference is that the interop site supports the new W3C policy namespace while WSIT uses the member submission policy namespace. The address for our web site is http://wsinterop.sun.com:3280/wspolicy_interop/.

The site is meant to demonstrate the current technology and aid our interop testing. I will keep it up as long as I can, but it is not meant to stay up forever or feature product quality. If you are having any issues with the site, please let me know.

Technorati:

Friday May 04, 2007

WSIT and WS-Policy at JavaOne 2007

We have quite a number of sessions, BOFs and labs that talk about Web Services, JAX-WS, WSIT and .NET interoperability. WS-Policy plays a role everywhere that WSIT is covered. It is the base technology to configure all the required functionality. You may find me at POD #966 or our hands-on lab. Here is a list of events (shamelessly stolen and adapted from Arun Gupta's blog):
 

Time Session ID/Title Speaker(s)
Monday, 05/08/07
10:30 AM - 7:30 AM GlassFish Day @ Community One  
Tuesday , 05/08/2007
11:15 AM - 1:15 PM Java EE SDK & Web Services Interoperability Technology booth duty (pod #966) Martin Grebac
1:00 PM - 3:00 PM Java EE SDK & Web Services Interoperability Technology booth duty (pod #966) Bhakti Mehta
2:45 AM - 4:45 PM Java EE SDK & Web Services Interoperability Technology booth duty (pod #966) Fabian Ritzmann
Wednesday, 05/09/2007
3:50 PM - 5:20 PM LAB-3350
Make Java Technology and .NET 3.0 Interoperability Work With WSIT
Martin Grebac; Sreejith A K
4:10 PM - 5:10 PM TS-4865
Takes two to Tango: Java Web Services and .NET Interoperability
Arun Gupta; Harold Carr
7:55 PM - 8:45 PM BOF-6412
Describing RESTful Applications: WADLing with Java
Marc Hadley
Thursday , 05/10/2007
11:15 AM - 1:15 PM Java EE SDK & Web Services Interoperability Technology booth duty (pod #966) Ashutosh Shahi, Shyam Rao
1:00 PM - 3:00 PM Java EE SDK & Web Services Interoperability Technology booth duty (pod #966) Sreejith A K
2:45 PM - 4:45 PM Java EE SDK & Web Services Interoperability Technology booth duty (pod #966) Sreejith A K; Arun Gupta
2:50 PM - 3:50 PM TS-4948
Unleashing the Power of JAX-WS RI: Spring, Stateful Web Services, SMTP, and More
Kohsuke Kawaguchi; Jitendra Kotamraju
5:30 PM - 6:30 PM TS-8840
Services Interoperability with Java Technology and .NET: Technologies and Tools for Web 2.0
Marina Fisher; Gerald Beuchelt
7:55 PM - 8:45 PM BOF-4108
Interoperable Web Services Security between Java Technology and .NET 3.0 with WSIT: Ease of Developement and Performance
Jiandong Guo; Ashutosh Shahi; Shyam Rao
Friday , 05/11/2007
10:50 AM - 11:50 AM TS-8029
Bridging the Gap: Using Java Technology and .NET Together in Harmony
Ted Neward
1:30 PM - 2:30 PM TS-4865
Takes two to Tango: Java Web Services and .NET Interoperability
Arun Gupta; Harold Carr

 

Thursday Feb 22, 2007

WS-Policy in WSIT milestone 3

With WSIT milestone 3, we are now shipping a complete WS-Policy implementation. WSIT provides an open-source and fully compliant implementation of WS-Policy 1.2 and WS-PolicyAttachment 1.2. We have lately been able to solely focus on fixing bugs and polishing the code and documentation and we currently have only very few open bugs . This seems like a good time to examine how WSIT supports WS-Policy more closely. And if you are wondering now what WS-Policy is in the first place, take a look at Marek Potociar's blog .

WSIT is an extension of JAX-WS and part of the GlassFish community. JAX-WS supports quite a number of approaches to develop and configure a web service. You can start with plain Java code and use annotations. If you need maximum flexibility, you would implement the Provider interface. If you have a WSDL document, you may want to start by having JAX-WS generate a service endpoint interface. There may be some deployment descriptors that allow you to configure your web service, see e.g. JSR 109. And on the client, you can use WebServiceFeatures.

Generally, the WS-Policy support in WSIT distinguishes between whether you develop your service starting from Java or WSDL. If you provide a WSDL document with your service, WSIT uses it and the contained policies to configure the system. The WSDL document is published almost unaltered. I am saying almost because this WSDL may contain policy assertions that are considered private. You can e.g. specify the password of a certificate store with a policy assertion. This and similar elements are automatically removed from the WSDL document before it is published.

When a service is developed from Java without any WSDL, WSIT relies on a separate configuration file. The file format is almost valid WSDL 1.1 and the actual configuration settings are contained as policies. That makes it very easy when JAX-WS generates a WSDL document for the service to attach the given policies to the generated WSDL document. As is the case when you develop your service from WSDL, private policy assertions are removed before the final WSDL is published.

Web service clients retrieve the WSDL of the service that they want to talk to. If that WSDL document contains policies, the client configures itself automatically to comply with the requirements of the service. Note that a client usually retrieves the service WSDL at run-time, i.e. the client configures itself at run-time as well. That makes it very easy to e.g. tighten the configuration of a web service in production without having to change or redeploy any client. (There is one exception to that rule, namely if you are using WS-AtomicTransaction, but then you have to adapt your code to deal with transactions anyway.)

The WSIT client can additionally read a separate configuration file. That configuration file serves two purposes. It allows to configure client-only settings, e.g. the certificate store of the client. And in case the service WSDL does not have any policies or the service has no retrievable WSDL at all, the service policies can be added to the client configuration instead. The client configuration file has the same format as the service configuration file, i.e. it is almost valid WSDL 1.1.

Technorati:

Tuesday Feb 06, 2007

How to configure logging in GlassFish for the WS-Policy implementation in WSIT II

How to configure logging in GlassFish for the WS-Policy implementation in WSIT by editing domain.xml.[Read More]

Tuesday Jan 30, 2007

Configure java.util.logging at run-time

Configure java.util.logging at run-time[Read More]

Thursday Nov 23, 2006

Is catching NoClassDefFoundError more efficient than using reflection?

Is catching java.lang.NoClassDefFoundError more efficient than using reflection?

Catching java.lang.NoClassDefFoundError is not portable across JVMs and we must use reflection.

[Read More]


Archives
Links
Referrers