Tuesday, March 24, 2009

Installing MLR#3 on SOA Suite 10.1.3.4

Unzip MLR3 patch to a directory of your choice.
copy the directory 7586063 to the soaSuiteHome\opatches directory

Open a CMD window in this directory

set Oracle_home=d:\soa10134\appserver
set PERL5LIB=d:\soa10134\appserver\perl\5.8.3\lib
set OPATCH_PLATFORM_ID=0
set path=d:\soa10134\appserver\OPatch;%path%

Apply the patch -
opatch apply

Post-Steps
DB Schema upgrade

ORABPEL- according to the patch README, if you're pure 10.1.3.4 then you must run the following to update the schema
upgrade_10134_10134mlr_above_mlr11_oracle.sql
In my case the file is located at -
D:\SOA10134\AppServer\bpel\system\database\scripts

ORAESB - run the following -
SQL> @$ORACLE_HOME/integration/esb/sql/oracle/upgrade_10134_10134MLR.sql

In my case the file is located at -
D:\SOA10134\AppServer\integration\esb\sql\oracle

XREF: xREF Schema update. I've not used ESB xrefs so they don't need updating

Restart Soa Suite 10.1.3.4
opmnctl startall

Tuesday, March 10, 2009

Calling async BPEL process from JDEV 11g

Here is a simple example

· Create a simple asynchronous BPEL process
o Accept a String as input
o Do some simple processing and return the string as output



· Deploy to BPEL
· Get BPEL wsdl




· Create a new Application & Project in JDev 11g
In the project, create a Web Service Proxy



· Select Initiate Service à SimpleAsyncHello



· Click Finish

· The following artifacts are created



The 2 interesting files in respect of this lab are –

· SimpleAsyncHelloPortClient
o à Initiate BPEL process

· SimpleAsyncHelloCallbackImpl
o à Receive Callback from BPEL Server

As mentioned in the JDEV 11g release notes, we will have to make some changes to the SimpleAsyncHelloPortClient as BPEL 10.1.3.4 uses 2003 style addressing.


Original SimpleAsyncHelloPortClient –

public static void main(String [] args)
{
simpleAsyncHello_Service = new SimpleAsyncHello_Service();
SimpleAsyncHello simpleAsyncHello = simpleAsyncHello_Service.getSimpleAsyncHelloPort();
// Get the request context to set the outgoing addressing properties
WSBindingProvider wsbp = (WSBindingProvider)simpleAsyncHello;
WSEndpointReference replyTo =
new WSEndpointReference("http://", WS_ADDR_VER);
String uuid = "uuid:" + UUID.randomUUID();

wsbp.setOutboundHeaders( new StringHeader(WS_ADDR_VER.messageIDTag, uuid), new StringHeader(WS_ADDR_VER.actionTag, "action" ), replyTo.createHeader(WS_ADDR_VER.replyToTag));

// Add your code to call the desired methods.
}



Revised SimpleAsyncHelloPortClient –

· Imports

import com.oracle.xmlns.simpleasynchello.SimpleAsyncHello;
import com.oracle.xmlns.simpleasynchello.SimpleAsyncHello_Service;

import com.sun.xml.ws.api.addressing.AddressingVersion;
import com.sun.xml.ws.api.addressing.WSEndpointReference;
import com.sun.xml.ws.developer.WSBindingProvider;
import com.sun.xml.ws.message.StringHeader;

import java.util.UUID;

import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceRef;

import org.xmlsoap.schemas.ws._2003._03.addressing.AttributedURI;
import org.xmlsoap.schemas.ws._2003._03.addressing.EndpointReferenceType;

· Main method

public static void main(String [] args)
{
simpleAsyncHello_Service = new SimpleAsyncHello_Service();
SimpleAsyncHello simpleAsyncHello = simpleAsyncHello_Service.getSimpleAsyncHelloPort();
// Get the request context to set the outgoing addressing properties
WSBindingProvider wsbp = (WSBindingProvider)simpleAsyncHello;

String uuid = "uuid:" + UUID.randomUUID();

// Add your code to call the desired methods.
//
AttributedURI messageId = new AttributedURI();
messageId.setValue( "uuid:" + UUID.randomUUID() );

// prepare ReplyTo
AttributedURI address = new AttributedURI();
address.setValue("http://localhost:7101/MyBPELAsyncClient-MyBPELClient-context-root/SimpleAsyncHelloCallbackPort");
EndpointReferenceType replyTo = new EndpointReferenceType();
replyTo.setAddress( address );

// prepare action header
wsbp.setOutboundHeaders(new StringHeader(
new QName( "http://schemas.xmlsoap.org/ws/2003/03/addressing", "Action" ),
"http://xmlns.oracle.com/SimpleAsyncHello/SimpleAsyncHello/initiate" ));

// Prepare payload
SimpleAsyncHelloProcessRequest asyncHelloProcessRequest = new SimpleAsyncHelloProcessRequest();
asyncHelloProcessRequest.setInput("Hi There");
simpleAsyncHello.initiate(asyncHelloProcessRequest, replyTo,messageId );

}

So what have we done here?

· Prepare ReplyTo:
· http://localhost:7101/MyBPELAsyncClient-MyBPELClient-context-root/SimpleAsyncHelloCallbackPort
o BPEL will reply to a service running on WLS. This service has been generated for us SimpleAsyncCallbackImpl.
o To test this, simply select this class and Right-mouse Click Run.This will deploy it to the embedded WLS that comes with JDev.

· Test the URL in a browser




· Check the wsdl for the port location




· http://localhost:7101/MyBPELAsyncClient-MyBPELClient-context-root/SimpleAsyncHelloCallbackPort


· Prepare Action Header (for 2003 compatability)
wsbp.setOutboundHeaders(new StringHeader(
new QName( "http://schemas.xmlsoap.org/ws/2003/03/addressing", "Action" ),
"http://xmlns.oracle.com/SimpleAsyncHello/SimpleAsyncHello/initiate" ));

· Prepare Payload (BPEL process input) and invoke the initiate method
SimpleAsyncHelloProcessRequest asyncHelloProcessRequest = new SimpleAsyncHelloProcessRequest();
asyncHelloProcessRequest.setInput("Hi There");
simpleAsyncHello.initiate(asyncHelloProcessRequest, replyTo,messageId );


· Test
o Run SimpleAsyncHelloPortClient
o Check BPEL Console




So now it’s time to look at the implementation of the Callback

· Original SimpleAsyncHelloCallbackImpl


package com.oracle.xmlns.simpleasynchello;

import com.sun.xml.ws.api.addressing.AddressingVersion;
import com.sun.xml.ws.api.message.Header;
import com.sun.xml.ws.api.message.HeaderList;
import com.sun.xml.ws.developer.JAXWSProperties;

import javax.annotation.Resource;

import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.jws.soap.SOAPBinding.Style;

import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.soap.Addressing;
// !THE CHANGES MADE TO THIS FILE WILL BE DESTROYED IF REGENERATED!
// This source file is generated by Oracle tools
// Contents may be subject to change
// For reporting problems, use the following
// Version = Oracle WebServices (11.1.1.0.0, build 080922.1045.35800)

@WebService(targetNamespace="http://xmlns.oracle.com/SimpleAsyncHello",
name="SimpleAsyncHelloCallback")
@XmlSeeAlso(
{ org.xmlsoap.schemas.ws._2003._03.addressing.ObjectFactory.class, com.oracle.xmlns.simpleasynchello.ObjectFactory.class })
@SOAPBinding(style=Style.DOCUMENT, parameterStyle=ParameterStyle.BARE)
@Addressing(enabled=true, required=true)
public class SimpleAsyncHelloCallbackImpl
{
@Resource
private WebServiceContext wsContext;

private static final AddressingVersion WS_ADDR_VER = AddressingVersion.W3C;

@WebMethod(action="onResult")
@SOAPBinding(parameterStyle=ParameterStyle.BARE)
@Action(input="onResult")
@Oneway
public void onResult(@WebParam(targetNamespace="http://xmlns.oracle.com/SimpleAsyncHello",
partName="payload", name="SimpleAsyncHelloProcessResponse")
com.oracle.xmlns.simpleasynchello.SimpleAsyncHelloProcessResponse payload,
@WebParam(targetNamespace="http://schemas.xmlsoap.org/ws/2003/03/addressing",
partName="RelatesTo", name="RelatesTo", header=true)
org.xmlsoap.schemas.ws._2003._03.addressing.Relationship RelatesTo)
{
// Use the sample code to extract the relatesTo id for correlation and then add your rest of the logic

System.out.println("Received the asynchronous reply");

// get the messageId to correlate this reply with the original request
HeaderList headerList = (HeaderList)wsContext.getMessageContext().get(JAXWSProperties.INBOUND_HEADER_LIST_PROPERTY);
Header realtesToheader = headerList.get(WS_ADDR_VER.relatesToTag, true);
String relatesToMessageId = realtesToheader.getStringContent();
System.out.println("RelatesTo message id: " + relatesToMessageId);

System.out.println("payload: '" + payload + "'");
System.out.println("RelatesTo: '" + RelatesTo + "'");
// Add your implementation here.
}
}

· Revised SimpleAsyncHelloCallbackImpl


package com.oracle.xmlns.simpleasynchello;

import com.sun.xml.ws.api.addressing.AddressingVersion;
import com.sun.xml.ws.api.message.Header;
import com.sun.xml.ws.api.message.HeaderList;
import com.sun.xml.ws.developer.JAXWSProperties;

import javax.annotation.Resource;

import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.jws.soap.SOAPBinding.Style;

import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.soap.Addressing;
// !THE CHANGES MADE TO THIS FILE WILL BE DESTROYED IF REGENERATED!
// This source file is generated by Oracle tools
// Contents may be subject to change
// For reporting problems, use the following
// Version = Oracle WebServices (11.1.1.0.0, build 080922.1045.35800)

@SOAPBinding(style=Style.DOCUMENT, parameterStyle=ParameterStyle.BARE)
@WebService(name = "SimpleAsyncHelloCallback", targetNamespace = "http://xmlns.oracle.com/SimpleAsyncHello", portName = "SimpleAsyncHelloCallbackPort")
public class SimpleAsyncHelloCallbackImpl
{
@Resource
private WebServiceContext wsContext;

private static final AddressingVersion WS_ADDR_VER = AddressingVersion.W3C;

@SOAPBinding(parameterStyle=ParameterStyle.BARE)
@Action(input="onResult")
@Oneway
@WebMethod(action = "onResult")
public void onResult(@WebParam(targetNamespace="http://xmlns.oracle.com/SimpleAsyncHello",
partName="payload", name="SimpleAsyncHelloProcessResponse")
com.oracle.xmlns.simpleasynchello.SimpleAsyncHelloProcessResponse payload,
@WebParam(targetNamespace="http://schemas.xmlsoap.org/ws/2003/03/addressing",
partName="RelatesTo", name="RelatesTo", header=true)
org.xmlsoap.schemas.ws._2003._03.addressing.Relationship RelatesTo)
{
// Use the sample code to extract the relatesTo id for correlation and then add your rest of the logic

System.out.println("Received the asynchronous reply");

// get the messageId to correlate this reply with the original request
HeaderList headerList = (HeaderList)wsContext.getMessageContext().get(JAXWSProperties.INBOUND_HEADER_LIST_PROPERTY);
Header relatesToheader = headerList.get(WS_ADDR_VER.relatesToTag, true);

if (relatesToheader == null){
System.out.println("Header null");
}
// String relatesToMessageId = relatesToheader.getStringContent();
// System.out.println("RelatesTo message id: " + relatesToMessageId);

System.out.println("payload: '" + payload + "'" + payload.getResult());
System.out.println("RelatesTo: '" + RelatesTo + "'");
// Add your implementation here.
}
}

· Test and review output in the WLS console tab in JDEV