Pages

Monday, December 3, 2007

11g web services and policies

Creating web service in jdeveloper 11G with logging, security and mtom policies is a lot easier then in 10.1.3 . 11G support version 2 of JAX-RPC named JAX-WS. You can make a web service now by just putting some annotations like @WebService before the class name. JDeveloper automatically assist you by making the project web service enabled. We have a working web service with only one class. The oc4j container handles the rest. Here you have a simple example

package nl.ordina.ws;

import javax.jws.WebService;

@WebService
public class Welcome {

public String WelcomeText() {
return "hello";
}
}

you can configure it a little bit more

package nl.ordina.ws;

import javax.jws.WebService;

import oracle.webservices.annotations.AddressingPolicy;
import oracle.webservices.annotations.Deployment;
import oracle.webservices.annotations.ManagementPolicy;
import oracle.webservices.annotations.ReliabilityPolicy;

@WebService(name = "WebService", serviceName = "WebService", portName = "WebServicePort")
@Deployment(restSupport = true)
@ReliabilityPolicy("oracle/wsrm11_policy")
@AddressingPolicy("oracle/wsaddr_policy")
@ManagementPolicy( { "oracle/log_policy" })
public class Welcome {

public String WelcomeText() {
return "hello";
}
}

You can see that I use annotations for applying policies. Oracle provides a good example for this where for example the username_token_service_policy is explained. Too bad on the other security policies there is in this TP2 release no documentation or examples providid. In 10.1.3 there was a wizard which does the same but it's generate a lot of code. The policies are located at
j2ee\home\gmds\owsm\policies.
You can always use the option of creating web service the old fashion way ( jax-rpc annotated web service). This generates the wsdl and some more xml's but here you can use the same policies. This time the policies are stored in the oracle-webservices.xml file. see the xml file below

2 comments:

  1. Hi,

    Do you know how to test oracle/wsrm11_policy on the WLS 10.3.1

    ReplyDelete
  2. Hi,

    Did you see this http://biemond.blogspot.com/2009/09/wsm-in-fusion-middleware-11g.html

    hope this helps.

    thanks Edwin

    ReplyDelete