Monday, October 10, 2011

OEG - Oracle Enterprise Gateway Throttling - Part2

In this scenario have requests from Gold and Silver customers.
• Gold customers may execute 10 requests per minute
• Silver customers may execute 5 requests per minute

The customer status is stored in the http header – custStatus.

I created the following policies in OEG Policy Studio –

To begin with I create a policy for Silver customers -



I then create one for gold customers -




I create a 3rd policy - StatusBasedThrottling which essentially does the following -

1

- Extract the custStatus
- Switch on the custStatus value calling either the gold or silver policy
- Success Path - just reflect the message back to the caller
- Failure Path - trigger an email alert
- save the request to a message queue for later processing.

Let's see how each has been defined -











Now we need to configure the External Connection for JMS -

Create a JMS Q and Connection Factory on WLS -

jms/myThrottlingQueue
jms/myCF






In a previous step we have configured the Messaging System filter to write to
jms/myThrottlingQueue





Now I create a relative path -




Now we can deploy the policy, but first we need to add wls client to the oeg classpath -



Restart OEG and you will see the JMS lookup -



Test using Service Explorer -



The 6th request returns an error





Check email




Check Queue

OEG - Oracle Enterprise Gateway - Throttling

Simple example - throttle to only 5 requests per minute.

This builds on the example detailed in the previous OEG blog posting.

http://niallcblogs.blogspot.com/2011/09/registering-web-service-with-oracle.html

We will now amend the generated circuit (or shall we say, policy pipeline) to throttle requests to 5 per minute and email the Sys admin in case of violation.

We do this using the Throttling filter -



It is configured as follows -



Now we need to set up the connection to the EMAIL server (I'm using James for this)

We need to add an Alert destination -



Configured as follows -



Naturally, I have already created a user oegadmin on James - adduser oegadmin welcome

Now I configure an Alert filter in the policy (Failure Path) -






Deploy and test -

We can use Service Explorer and simple click run 6 times to see throttling in action.

I then check my email -



However, there is an easier way of doing this. We can use the OEG sr cmdLine tool to send the requests for us -



sr -h localhost -u/NiallsCreditCardService -s 8082 -p 10 -d10

The parameter definitions -




Now you be asking what is this /NiallsCreditCardService ?
this is simply a relative path I created on OEG -



essentially virtualising the backend service for us.

Friday, September 30, 2011

Cobol on the Bus Part 3

This time I have a somewhat more complex payload -

01 XXX.
05 XXX-STRUCT.
10 XXX-USER PIC X(04).
10 XXX-CODE PIC 9(08).

05 YYY-TAB.
07 YYY-DETAIL OCCURS 2 TIMES.
10 YYY-A PIC X(01).
10 YYY-B PIC S9(16)v9(2).
10 YYY-C PIC S9(16)v9(2).
10 YYY-D PIC S9(16)v9(2).
10 YYY-E PIC S9(3)v99.
05 YYY-END PIC 9(04).

I create a new OSB project in OEPE and import this copybook via MFL.






Test




Normally one would generate the non-XML data first -




and lo and behold - we get the following error.



The error - Too many digits - is understandable once we do the following -

Generate XML data






yyy-e has been defined as PIC S9(3)v99 e.g. 433.30
The generated XML value is 4333

Change this to 433.3 (the 2 occurances) and transform xml to non-xml






I change the non-xml value of user and click transform
Now I get the error -



yyy-b is defined as follows -
YYY-B PIC S9(16)v9(2).


MFL wise - It is defined as follows -




Change it (and the other signed fields) as follows -



Re-test - Generate XML

Change yyy-e values to include decimal point.



Transform XML to non-XML

Change the xxx-user value and Transform non-XML to XML



Naturally all these settings are contingent on the Mainframe sending the Cobol on to the bus. This could be over TCP-IP so you could use the Socket adapter, or maybe MQ is being used. Also one needs test data from the mainframe to see how the sign is being handled etc.

However, in the context of a POC...

Wednesday, September 21, 2011

Registering a Web Service with Oracle Enterprise Gateway (OEG)

Simple sanity test for OEG install.

I have created and deployed a simple creditCardValidation service to

http://localhost:7001/ValidateCC/ValidateCCPort?WSDL

The impl is as follows -

package validatecc;

public class ValidateCC {
public ValidateCC() {
super();
}
public CreditCardValidation validateCard(String cardType, String cardNr){
CreditCardValidation ccv = new CreditCardValidation();
ccv.setStatus("INVALID");

if (cardType.equalsIgnoreCase("AMEX")){
ccv.setValidFrom("20110101");
ccv.setValidUntil("20150101");
ccv.setCustName("NiallC");
ccv.setLimit(10000);
ccv.setStatus("VALID");

}
if (cardType.equalsIgnoreCase("VISA")){
ccv.setValidFrom("20070101");
ccv.setValidUntil("20110101");
ccv.setCustName("NiallC");
ccv.setLimit(7000);
ccv.setStatus("VALID");

}
return ccv;
}
}

package validatecc;

public class CreditCardValidation {
String validFrom;
String validUntil;
String custName;
String status;
int limit;

public CreditCardValidation() {
super();
}

public void setValidFrom(String validFrom) {
this.validFrom = validFrom;
}

public String getValidFrom() {
return validFrom;
}

public void setValidUntil(String validUntil) {
this.validUntil = validUntil;
}

public String getValidUntil() {
return validUntil;
}

public void setCustName(String custName) {
this.custName = custName;
}

public String getCustName() {
return custName;
}

public void setLimit(int limit) {
this.limit = limit;
}

public int getLimit() {
return limit;
}

public void setStatus(String status) {
this.status = status;
}

public String getStatus() {
return status;
}
}

Simple enough!

Steps

Start up the Gateway & Policy Studio

Gateway startup --> \OEG\Gateway\enterprisegateway\Win32\bin\enterprisegateway.bat
Policy Studio Startup --> \OEG\PolicyStudio\oegpolicystudio\policystudio.exe



Click on the Edit Active Configuration link
This loads the current Gateway configuration into Policy Studio.

Click on Policies
Click on Register Web Service








This is just a simple pass through example so de-select teh "secure" checkbox.



Check the routing settings




As you can see, this is simple pass-thru processing.

Now deploy the changes from Policy Studio to the Gateway.




Review what has been generated -



Right Click on the Service Handler --> Edit



Click on the Validation tab



Test using Service Explorer

I didn't cover the install of Service Explorer in my "OEG Install" blog post.
It is just a case of unzipping the file - Oracle_Enterprise_Gateway_11_1_1_5_0_Win32_Service_Explorer.zip to a directory of your choice.

Start -




You are presented with an empty page - ready for exploring!




Menu --> File --> Load WSDL

Here we load our original WSDL.




Change the Request, adding valid cardType etc.





Click on the drop down list beside the green icon




Change to point to OEG
http://8082/ValidateCC/ValidateCCPort
The default port for OEG is 8080, however I changed this to 8082, as I had a DB service running on 8080.



Validate the response





Monitor the Gateway





admin/changeme
Click on View Reports

Friday, September 16, 2011

Installing/Configuring Oracle Enterprise Gateway on Windows

The software is available on OTN, just click on the download link at -
http://www.oracle.com/technetwork/middleware/id-mgmt/oeg-300773.html

Then simply follow my doc -

https://docs.google.com/leaf?id=1D0Z0KfgFdvqGHIcpG_7B32mWImGGCRkWhO882KyRVJFYAx94QK9yf6vVTjQP&hl=en

Wednesday, September 14, 2011

OEG - Oracle Enterprise Gateway

I'm currently in Santa Clara skilling up on OEG, which can secure access to your services etc. from the outside world. It works in conjunction with WSM. Think of it as taking care of security in the DMZ, working in concert with WSM which takes care of the last mile security.

To quote from OTN -

Oracle Enterprise Gateway provides DMZ-class security and a comprehensive threat defense system at the service perimeter to SOA and Cloud environments, thus providing critical protection needed between un-trusted and trusted zones.


A very compelling addition to our stack -

So I strongly suggest you check out the many resources available on OTN -
http://www.oracle.com/technetwork/middleware/id-mgmt/oeg-300773.html