Thursday, October 17, 2013

OSB - Remove Namespace using XQuery



Recently, we came across a requirement , where we need to remove name space of XML before we send to MQ. this case IBM I Series application is receiving data from processing .

This is very common requirements specially when we are integrating with legacy system.  In order to achieve functionality, I use below X-Query function. 

Name -RemoveNamespace

xquery version "1.0" encoding "Cp1252";
(:: pragma  parameter="$anyType1" type="xs:anyType" ::)
(:: pragma  type="xs:anyType" ::)

declare namespace xf = "http://www.officedepot.org/Order/Remove_Namespace/";

declare function xf:removeNamespace($e as element())as element()
{element { xs:QName(local-name($e)) }
{ for $child in $e/(@*,node())
 return  
 if ($child instance of element())
    then xf:removeNamespace($child)
       else $child
       }
 };

declare variable $e as element() external;

xf:removeNamespace($e)

Now, we need to use replace action in proxy message flow to execute this XQuery, 






In side Proxy Flow, add replace action

Select "Replace node contents" radio button
XQuery  Bind Variables should be $body . Please note , it is not  $body/* .


This will remove namespace elements from XML . Happy codding. :)

Wednesday, October 9, 2013

SOA : XPATH BPEL4WS spec 1.1 section 14.3 Error

Some time we will be getting below error in BPEL flow for assign or transform activity.

<bpelFault><faultType>0</faultType><selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"><part name="summary"><summary>The &lt;from> value is invalid. The result of from-spec is null. Either the from node value or the xpath query in the from node value was invalid. According to BPEL4WS spec 1.1 section 14.3, the from node value should not be empty. Verify the from node value at line number no line in the BPEL source. </summary></part></selectionFailure></bpelFault>"

this can be happen either in assign or transform activity of BPEL flow. in order to avoid this error , assign dummy value to variable. This will be overwritten by the Assign activity in the next step anyways.

Happy codding :)

Tuesday, October 8, 2013

NTML Authentication - Oracle SOA suite

Recently my team had an issue where we need to call a NTML authenticated service and Oracle SOA suite, we are able to call from SOAP UI and not from BPEL SOA.
 

We tried different security header options and none of them is worked worked.

 

Current SOA is not support NTML authentication in Oracle SOA, we need to write a customer java code to call external NTML autheticated service.


In order to achieve that, we use java embedded inside  BPEL code to call external service. code looks .

 

 


 try {


 String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13";

 org.apache.commons.httpclient.HttpClient client = new org.apache.commons.httpclient.HttpClient();

 String soapAction ="NameSpaceof method"+"Method";

 org.apache.commons.httpclient.methods.PostMethod postMethod = new org.apache.commons.httpclient.methods.PostMethod("URL".trim());      postMethod.setRequestHeader("SOAPAction", soapAction);

 postMethod.setRequestHeader("Content-Type", "text/xml; charset=UTF-8");

 postMethod.setRequestHeader("SOAPAction", soapAction);

postMethod.setRequestHeader("User-Agent", userAgent);


postMethod.setRequestEntity(new org.apache.commons.httpclient.methods.StringRequestEntity(soapMessage.toString().trim(), "text/xml; charset=UTF-8", null));

String errorMessage ="";

String responseBodyString ="";


org.apache.commons.httpclient.NTCredentials ntCredentials = new org.apache.commons.httpclient.NTCredentials("Ravikumar-Punna", "xxxxxxx", "hostName", "NA");

client.getState().setCredentials(new org.apache.commons.httpclient.auth.AuthScope(null,-1,null), ntCredentials);

int status = client.executeMethod(postMethod);

if(status != org.apache.commons.httpclient.HttpStatus.SC_OK)

{

errorMessage = "Method Failed :" + postMethod.getStatusLine();

// System.out.println(errorMessage);

}

responseBodyString= postMethod.getResponseBodyAsString();

System.out.println("Response Message ;" +responseBodyString);


setVariableData("FantaticServiceResult", responseBodyString);

}catch(Exception e) {

}


 

 

This will call a NTML enabled external service .. simple :)

 

Jdeveloper Display line numbers in code editor

Quickest way to display line number in code editor , Right Click on  left hand side of code editor , then select "Toggle Line Numbers" . this will display line numbers in code editor - simple :)

 

Image

 

Have fun !

Thursday, October 27, 2011

"DEV_MDS.MDS_INTERNAL_SHREDDED" has errors while starting SOA Suite 11.1.1.5 server

I got below error while starting Oracle SOA Suite 11.1.1.5 server with on Oracle XE 10g  database.

MDS-01370: MetadataStore configuration for metadata-store-usage "OWSM_TargetRepos" is invalid.

ORA-04063: package body "DEV_MDS.MDS_INTERNAL_SHREDDED" has errors

ORA-06508: PL/SQL: could not find program unit being called: "DEV_MDS.MDS_INTERNAL_SHREDDED"

When this error happen SOA EM is not started and we can’t deploy any composites in SOA server.

Please follow below steps to resolve the issue.

1)      STOP SOA suite 11.1.1.5 server

2)      Drop the all SOA database schema using RCU.

once RCU drops the SOA database schemas like DEV_MDS connect to XE database using sqlplus command though command prompt.

  • Connect sys as SYSDBA and provide a password for SYS user


alter system set sga_target=350M scope=spfile;

alter system set sga_max_size=350M scope=spfile;

shutdown immediate

startup

once XE database is started. Set RCU_JDBC_TRIM_BLOCKS=TRUE  environment variable and run RCU to create SOA schema again.

Also before running rcu.bat file in command prompt . please check RCU_JDBC_TRIM_BLOCKS set properly.

  • Set RCU_JDBC_TRIM_BLOCKS=TRUE

  • Echo % RCU_JDBC_TRIM_BLOCKS %   -- this has to return TRUE


Now run rcu.bat in same command prompt window and create required schemas.

Note : This issue will happen only on XE 10g database.

Now start the SOA suite and deploy composites. Enjoy SCA development.

Monday, August 29, 2011

Receive EMAIL using OSB ( Oracle Service BUS)

Most of the guys know, how to send a email using OSB(Oracle service bus)  when we want to send notifications in business flow. sometimes, we might need to start our  business process by receiving an email from legacy system.

Recently, I come across POC. Where, we can trigger a OSB proxy service by sending an email with messages as email body.  The below steps will explain. How to create a proxy service which can receive emails and execute.

1)   First step is to create a static service account type. It will have credentials for mailbox( mainly user name , password).

Since, I am using my own mail server. I created mailbox user with web logic as user name for testing.


2)     second step, we need to create a proxy service that can listen to mail box  and execute message flow, whenever new mail arrives.

  1. Service type should be messaging service.

  2. Other configuration details can be found in below screen shot.




3)     Save changes and activate session. Now open message flow or proxy service to insert report action. in report action, we will print body and we can check body in sbconsole.


Now , the service is ready and it can trigger  by sending an email.

Thursday, July 14, 2011

OSB Internal Server Error - JMS Transaction rollback

This blog explain how to roll back a transaction in case of internal server errors in OSB. In general, if it gets any http response from the transport. There seem to be some ambiguity among product designers on interpreting http spec and they decided to treat any response as a success. This case transaction will not roll back and message will lost.

Scenario

JMS Queue -> OSB Proxy Service -> OSB  Business Service ->  Failing Service

To resolve the issues, please flow below steps in OSB proxy service.

1)      In Route node of routing options make  Quality of Service as ‘"Exactly Once”



2)      Enabled the Same Transaction for Response in the Proxy service which was listening to the JMS queue  –



3)      The Connection Factory used  to consume message from JMS queue should be  XA enable (XA connection factory).

4)      enabled XA required property for proxy service which is listening to JMS queue

5)      in JMS proxy Route Error handler do a raise error and Reply with Failure.



Once you make these necessary changes in proxy services. Activate changes and retest the flow. now you can observer the transaction will roll back in case of  ‘Internal server Error”  J