Using Oracle Database or Oracle EBS adapter for Oracle AQ (Advanced Queuing)

Here is a simple way to get started on Oracle AQ (Advanced Queuing) using the Oracle Database and/or Oracle E-Business Suite adapters. Here is what I did, right from defining my queue – one step at a time.


Step 1 – Define the queue payload type
CREATE TYPE AQ_MESSAGE_TYPE AS OBJECT (ID VARCHAR2(30), INFO VARCHAR2(200));


Step 2 – Define the queue table
EXEC  DBMS_AQADM.CREATE_QUEUE_TABLE(QUEUE_TABLE => ‘INFO’, QUEUE_PAYLOAD_TYPE => ‘AQ_MESSAGE_TYPE’);


Step 3 – Create the queue
EXEC DBMS_AQADM.CREATE_QUEUE(QUEUE_NAME => ‘AQ_MESSAGE_QUEUE’, QUEUE_TABLE => ‘INFO’);


Step 4 – Start the queue
EXEC DBMS_AQADM.START_QUEUE(QUEUE_NAME => ‘AQ_MESSAGE_QUEUE’);


Step 5 – Create a function to enqueue
CREATE OR REPLACE FUNCTION ENQUEUE_AQ_MESSAGE_QUEUE(PAYLOAD IN AQ_MESSAGE_TYPE) RETURN RAW
AS
 PROPERTIES DBMS_AQ.MESSAGE_PROPERTIES_T;
 MSGID RAW(16);
 OPTIONS DBMS_AQ.ENQUEUE_OPTIONS_T;
BEGIN
 DBMS_AQ.ENQUEUE(‘AQ_MESSAGE_QUEUE’,
    OPTIONS,
    PROPERTIES,
    PAYLOAD,
    MSGID);


 RETURN MSGID; 
END;


Step 6 – Create a function to dequeue
CREATE OR REPLACE FUNCTION DEQUEUE_AQ_MESSAGE_QUEUE(PAYLOAD OUT AQ_MESSAGE_TYPE) RETURN RAW
AS
 PROPERTIES DBMS_AQ.MESSAGE_PROPERTIES_T;
 OPTIONS DBMS_AQ.DEQUEUE_OPTIONS_T;
 MSGID RAW(16);
 NOTHING_TO_DEQUEUE EXCEPTION;  
 PRAGMA   
 EXCEPTION_INIT (NOTHING_TO_DEQUEUE, -25228);
BEGIN
 OPTIONS.WAIT := DBMS_AQ.NO_WAIT;
 DBMS_AQ.DEQUEUE(‘AQ_MESSAGE_QUEUE’,
    OPTIONS,
    PROPERTIES,
    PAYLOAD,
    MSGID);
 RETURN MSGID;
EXCEPTION
 WHEN NOTHING_TO_DEQUEUE
  THEN RETURN NULL;
END;


A word on dequeue and enqueue functions – these are simplistic in this example. You might want to modify them to take more inputs (for example – more message properties or enqueue/dequeue properties as input). The dequeue function returns immediately if a message is not available for dequeue and returns null in that case. You could tweak that too.


Step 7 – Call the functions using the adapter!
It is easy calling these from the adapter now. The reason why the DBMS_AQ.ENQUEUE and DBMS_AQ.DEQUEUE cannot be called directly from the adapter is that they use complex data types that are not supported by ODP.NET. One can now even call the dequeue function in a polling context, and get messages delivered to them as they are pushed into the queue! The links to portions of the Oracle Database adapter help that will help you do this are:



Thanks to Mustansir for suggesting this blog idea!

"The security validation for this page is invalid" when calling the SharePoint Web Services

When working with the out-of-the-box SharePoint web services, it may have happened to you that the Web Service response contained the following exception embedded in the XML:

Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ was thrown.
The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
Error code: 0x8102006d

Undoubtedly this exception is quite strange in the context of a web service call; there is no Back button you can click. But in my cases the exception was just plain wrong, the issue had nothing to do with security whatsoever. It turned out that when you make a web service call to the SharePoint web services, in some cases you need to set the SOAPAction header  in the HTTP Request, in other cases it’s not necessary to do this (but it won’t do any bad if you do). When you consume web services from .NET code, you probably have Visual Studio generated proxies; they pass the correct header so you don’t need to do anything special. But if you construct your own HTTP Request to make the Web Service call, for example using Javascript and jQuery, you need to think about this. Check out following Javascript code for example, which creates a new List item by using the Lists.asmx web service (discussed in more detail in my previous post):

var soapEnv =
    “<?xml version=\”1.0\” encoding=\”utf-8\”?> \
    <soap:Envelope xmlns:xsi=\”http://www.w3.org/2001/XMLSchema-instance\” \
        xmlns:xsd=\”http://www.w3.org/2001/XMLSchema\” \
        xmlns:soap=\”http://schemas.xmlsoap.org/soap/envelope/\”> \
      <soap:Body> \
        <UpdateListItems xmlns=\”http://schemas.microsoft.com/sharepoint/soap/\”> \
          <listName>Tasks</listName> \
          <updates> … Updates XML … </updates> \
        </UpdateListItems> \
      </soap:Body> \
    </soap:Envelope>”;

$.ajax({
    url: “http://yoursite/_vti_bin/lists.asmx”,
    type: “POST”,
    dataType: “xml”,
    data: soapEnv,
    complete: processResult,
    contentType: “text/xml; charset=utf-8”
});

This code will cause the Security Validation exception, because the SOAPAction Header is not correct. How do you know what value you need to set the SOAPAction Header to? Well, that’s very easy to figure out! Just navigate the the Lists.asmx web service (or UserGroup.asmx, Webs.asmx, Sites.asmx, SiteData.asmx or any Web Service you want to call of course) in your browser, and drill down to the Web Method you want to invoke.

 

As you can see, the required value of the SOAPAction value is displayed in the generated web page for the Web Method, so you can just copy and paste it in your code. When using the jQuery ajax function, you can use the beforeSend option so set additional Headers:

$.ajax({
    url: wsURL,
    beforeSend: function(xhr) {
        xhr.setRequestHeader(“SOAPAction”,
        “http://schemas.microsoft.com/sharepoint/soap/UpdateListItems”);
    },

    type: “POST”,
    dataType: “xml”,
    data: soapEnv,
    complete: processResult,
    contentType: “text/xml; charset=utf-8”
});

That’s it, now the Web Service call will work without the irrelevant Security Validation exception.

Windows Application Server Enhancements known as Dublin Presentation in Sweden

On Thursday June 4th I will be presenting in Sweden to the BizTalk Users Group. I am excited to be making the trip to Sweden and it will be great to see so many BizTalk enthusiasts all in one place.  I will be presenting two sessions both on Microsoft’s new Window Application Server Enhancements – known as “Dublin”.  The details of the sessions are below.  If you are in Stockholm and want to attend you can get information on the BizTalk Users Group home page. 

Meeting Title:  Inside the Windows Application Server Enhancements known as Dublin

Session 1: Walkthrough of Windows Application Server Enhancements code named Dublin

In this session we will review the features of the Windows Application Server Enhancements code named Dublin.  This session will show how to use new and enhanced concepts in the .Net 4.0 framework to empower Services hosted in Windows allowing users insight into service health and activity.

Session 2: Managing, Monitoring, and Deploying Services using Windows Application Server Enhancements

This session takes a deeper dive into Windows Application Server Enhancements by looking in detail at the hosting of a Workflow Service.  This will cover reviewing a web service aggregator Workflow Service, setting up custom tracking, monitoring running services, and import and export of applications.  

Recent Links of Interest

Recent Links of Interest

It’s the Friday before a holiday here in the States so I’m clearing out some of the interesting things that caught my eye this week.

BizTalk “Cloud” Adapter is coming.  Check out Danny’s blog where he talks about what he demonstrated at TechEd.  Specifically, we should be on the lookout for a Azure adapter for BizTalk.  […]

Service Virtualization with the Microsoft Managed Services Engine

I presented at the Twin Cities Connected Systems User Group last night on the Managed Services Engine. You can get the presentation here.

The Managed Services Engine is a CTP technology that acts as a service intermediary. It helps abstract consumers form the services that they call, performing things such as xslt mapping, protocol switching, version mapping and service stubbing (useful for testing unhappy service respone paths as well as development of the consumerbefore the service is really ready.)

You can get the Managed Services Engine on CodePlex: http://www.codeplex.com/servicesengine

MockingBird- Beta 2

MockingBird- Beta 2

MockingBird – Beta 2 is now available.
The changes/ fixes are as follows
(1) The system can handle remote WSDL’s now (using DiscoveryClientProtocol). [But this will use the Default network credentials to get the WSDL. There are no facilities as yet for providing this information as settings for the tool).
(2) Fixed the WSDL Browser which crashed when […]