Category: soa

How to Indent XML String in Java (Pretty)

Hello Guys,

This is a cool way to prettify your XML (String format) in Java Language:


import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class FormatXML {

	public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException {
		System.out.println(format("YOUR_XML_HERE", true));
	public static String format(String xml, Boolean ommitXmlDeclaration) throws IOException, SAXException, ParserConfigurationException {
		DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
		Document doc = db.parse(new InputSource(new StringReader(xml)));
		OutputFormat format = new OutputFormat(doc);
		Writer outxml = new StringWriter();
		XMLSerializer serializer = new XMLSerializer(outxml, format);
		return outxml.toString();

Implementation of Oracle SOA Middleware products in companies

Hi People, tonight i was invited by to participate of a Podcast Session, a community of specialists at Oracle World through the planet. I’m am very happy with this, thank you OTechTalks.

This is my presentation to them:

Title: Implementation of Oracle SOA Middleware products in companies

  • Where to start ?
  • What are the benefits ?
  • What are the difficulties ?
  • What needs to be modified ?
  • Really worth the change ?
benefits-sign-forweb change-in-business oracle_soasuite_logo images


This podcast is a reflection on the practical experience of implementing Oracle SOA Middleware products experienced by Victor Jabur ( in some Brazilian companies. Let’s talk about the main difficulties, benefits, things that need to be modified to achieve success.

How you started journey with Oracle tech ?


I started my career at Oracle World in 2005 working as a developer in the Forms and Reports platform, using the PL / SQL language in a wholesale hypermarket company called Atacadão (, later worked in a database integration project, joining two banks, REAL and Unibanco. working for TCS ( In 2007, I had my first experience of implementing Oracle SOA Products at the company Sem Parar (, a pioneer in electronic billing passages in Brazilian toll through RFID tags in windshields of vehicles, with 12.5 million transactions a month and a turnover 1.68 billion reals in the same year. With experience acquired, I started to work in the SOA implementation of many companies, such as Fleury (, a Laboratory Medicine company, Edson Queiroz ( a famous multi-brand group, WTorre (, a construction company, Port of Santos (, development of a control system access for the main Brazilian port, Porto Seguro (, vehicle insurance company, among other companies. Currently working as a Solutions Architect at Pernambucanas (, the famous Brazilian Retail company where many Oracle products are used, and the main ongoing project is the implementation of Oracle Retail, coexisting with the Legacy in Forms and Reports and communicating with other modules like EBS, BI, CRM, Government Systems, External Partners, and so on. SOA is being implemented too, along with mobile and big data initiatives, being considered one of the most innovative companies in 2014 (, even with the age of 107 years old.

Brief topic of the day

DataOrProcess graphic039 Businessman looking at Innovation plan. Business background

For many years the Oracle sold in the market your product to Graphic User Interface development, launched in 1981 under the name Interactive Application Facility (IAF), changing its name to FastForms + IAG, becomes later SQL * Forms and more later Oracle Forms. Currently, Oracle is replacing the Forms for ADF technology (Advanced Development Framework), a new way of doing Screens in Java Language. Over all these years, many companies in Brazil and the world have used this tool, All the resources that was available were the database, PL / SQL, Forms/Reports and thus the entire business rules at the company were stored in the database through procedures or directly inside the Forms screens file. The world has evolved, competitiveness is much higher and companies need to be agile to keep up your market. You need to be close to the business, by changing its rules, making partnerships with other companies. The legacy left by Forms with all the business rule on the developer’s hand is not very good for the company, the business analyst does not know very well what rules are deployed, it is not easy nor quick for change them.

Fortunately Oracle followed the evolution acquiring partner companies, evolving their products and many of them focused in the business, implementing visual business flow (Business Process Execution Language – BPEL), business rules tools arrived, isolating business rules of the source code, making it very easy and fast editing. It’s not necessary implement your screen functions from scratch, a new paradigm emerged service-oriented-architecture (SOA), where there is a service bus that (Oracle Service Bus – OSB) exposes the enterprise service catalog and then, service is reused, saving up money with development, making it easy to maintain, starting new projects more easily, because with the reuse many things are ready when we need to build a new software in the enterprise. Partner companies could not communicate in the past because of the use of different programing languages and this is possible ​now by using WebServices over the internet, through the universal language called XML (Extensible Markup Language), new partnerships can be stablished, systems can be integrated and business leveraged. Manual processes made in the past by paper, email, phone calls, spreadsheets, tickets and text messages can now be computerized through the BPM (Business Process Management), the audit trail of approvals, analysis and comments are permanently saved, the information is protected, digitalizing process is saving the paper quantity used in times where the planet claims for help. Many governments have adopted processes digitalizing solutions, there is a product called Oracle UCM (Universal Content Management) that stores documents, even confidential, digitally signed with personal digital certificates, reducing fraud of manual signatures. Customers with mobile phones always is communicating with the companies: using the service channel to pay their bills, to buy products, ask for some support or share information. Smart shopping recommendation systems send messages to customers, encouraging them to buy. Really new times came, the technology has evolved, things are faster and who’s out of this process lose customers to the competitioners.

Said that, it is natural that many companies will want to apply these concepts, but where to start ? An important recomendation is that SOA is a concept, not a suite of tools that you can buy, install and all will be ok. Many companies are failing for not paying attention at this point. A cultural change is necessary, business leaders should take the lead and map very well their business processes, modelling the entities of your company, XML schemas known as Canonical Model, the developer no longer owns the business rules in the company, a renewal is required, the staff in many cases need to be replaced by others, with a more appropriated skills, if the company does not have an architecture team, this is a good start, create a team that advise the business people on how to things work, designing simple solutions to resolve complex problems. Oracle offers an excellent product, known as Soa Suite, a complete tool, with many effective resources, but alone it is not possible to cause any change at the company.

This work can start in a incremental way, with a little pilot of an important flow for the company and when the benefits have been demonstrated, the adoption can be increased for other projects of the company. You can start with the design of the business flows, modeling the corporate entities, electing candidates to become services, which in fact are reusable and increases value to the company, the business rules are created in the appropriated tool, then the previously flows designed can be implementated using BPEL languange for example, manual processes can be implemented in BPM, sensors measuring the business flows are installed, generating real time dashboards for business team, enabling them to act proactively to achieve the goals, for example, if the sale is not good and dashboards are indicating the bad scenario, promotions can be launched, actions are taken to encourage the sale in the shop and the situation can be reverted, as opposed to look at sales reports at end of the day or month and to check that the goal was not reached, proactivity is the keyword. Another common difficulty is that the SOA suite ships with many products (BPEL, BPM, OSB, BAM, ADF), people get lost, do not know what is the role of each product, implementing more things that should on a specific product. Here’s a tip on what and how to implement each module:

  • OSB: It should contain generic, reusable web services without any business rule, only routing and enrichment of messages.
  • BPEL: Light business flows, more complex rules must be implemented in any programming language and should be exposed as a service for a bpel flow orchestration, this flow represent the business, and not contain details of development implementation.
  • BPM: It must contain only the manual business flow, without business rules, it must rely on previously services made, almost never access directly the database, generally require notification services, whether e-mail, sms, social networking and others.
  • BAM: Monitoring Dashboards cannot cause overhead on the transactional database to generate the graphics, the necessary information should be used as an asynchronous messaging, sensors embedded in bpels or a replicated database to make the queries.
  • ADF: Framework that will replace Forms in the near future, screens are written in Java using Java Server Faces (JSF), all new Oracle products are already made using adf, enterprise manager for example. In BPM Suite, adf is widely used, because the screens are automatically generated in this product.

What is gained by doing this all worth it ?


The advantages are an I.T. department that speaks the language of business, saving money through reuse, automating manual processes that before were exposed to errors, agility for the company, fast changing their business rules reaching the necessary time to market, flexibility and high availability for all of these products work in auto scalable clusters ensuring maximum stability to the customer, ease of communication with external partners, security in communication and many other benefits.

What is needed to do this ?

A financial investment for the acquisition of software and hardware needed
Be aware that a culturally change is required in the company.
Relocate, demit, requalify and hire new people.
Rely on the expertise of qualified professionals to advise the company.
Breaking paradigms and accepting some risks.

What do you feel makes Oracle Users community special ?

Oracle is a large company present in many countries and special in this community is just it. The interaction with many cultures, and learning technology, you gain life experience.


If you could magically suggest all of your Oracle community members one thing in this world, what would it be, and why ?

I suggest that community members to create a personal blog, because of it i was invited to this podcast, invited to be a become a tecnical review of a book about Oracle ADF in last year and i often known people that come in at my blog of other countries. I feel very good about being helpful to people around the world.

For someone new to Oracle , how do they get the most out of it ? or how they should start a career in Oracle Middleware ?

There are many books about many products of Oracle Technology, mainly mostly books from Packt Publishing who is doing an excellent job around the world launching many books, written by members of the Oracle community around the world. For more senior people i recommend that they open schools and courses that offer Oracle Technology, my work friend try this here at Brazil ( and and it is success, training many people that offer more quality work for the Brazilian companies.

Thank you to OTechTalks to invite me for this Podcast Session. It was a pleasure to share my knowledge with the world, i am very happy with this.


Victor Jabur

How to consume a WebService that uses Ws-Security Authentication (UsernameToken) – OWSM – Oracle Service Bus (OSB)


The Oracle Service Bus (OSB) allows to enable OWSM authentication, there is many policies that can be applied to the Proxy Service to turn on security authentication. The most basic of this policies is:

oracle / wss_username_token_service_policy

Requiring only a username and password. Once enabled this security, following a tip on how to make a request using a Java Client.

File: – This is a main class to make a request

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;

import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class MainPost {

	public static void main(String[] args) {

		try {

			MyService service = new MyService();
			MyServicePort myServicePort = service.getMySoapPort();

			// This is the block that apply the Ws Security to the request
			BindingProvider bindingProvider = (BindingProvider) myServicePort;
			List<Handler> handlerChain = new ArrayList<Handler>();
			handlerChain.add(new WSSecurityHeaderSOAPHandler("myUsername", "myPassword"));

			RequestType myRequest = new RequestType();

			ResponseType response = myServicePort.searchSomething(myRequest);

		} catch (Exception e) {

File: – This is a handler responsible for creating the header authentication.

import java.util.Set;

import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;

public class WSSecurityHeaderSOAPHandler implements SOAPHandler<SOAPMessageContext> {

 private static final String SOAP_ELEMENT_PASSWORD = "Password";
 private static final String SOAP_ELEMENT_USERNAME = "Username";
 private static final String SOAP_ELEMENT_USERNAME_TOKEN = "UsernameToken";
 private static final String SOAP_ELEMENT_SECURITY = "Security";
 private static final String NAMESPACE_SECURITY = "";
 private static final String PREFIX_SECURITY = "wsse";

 private String usernameText;
 private String passwordText;

 public WSSecurityHeaderSOAPHandler(String usernameText, String passwordText) {
 this.usernameText = usernameText;
 this.passwordText = passwordText;

 public boolean handleMessage(SOAPMessageContext soapMessageContext) {

 Boolean outboundProperty = (Boolean) soapMessageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

 if (outboundProperty.booleanValue()) {

 try {
 SOAPEnvelope soapEnvelope = soapMessageContext.getMessage().getSOAPPart().getEnvelope();

 SOAPHeader header = soapEnvelope.getHeader();
 if (header == null) {
 header = soapEnvelope.addHeader();

 SOAPElement soapElementSecurityHeader = header.addChildElement(SOAP_ELEMENT_SECURITY, PREFIX_SECURITY,

 SOAPElement soapElementUsernameToken = soapElementSecurityHeader.addChildElement(SOAP_ELEMENT_USERNAME_TOKEN, PREFIX_SECURITY);
 SOAPElement soapElementUsername = soapElementUsernameToken.addChildElement(SOAP_ELEMENT_USERNAME, PREFIX_SECURITY);

 SOAPElement soapElementPassword = soapElementUsernameToken.addChildElement(SOAP_ELEMENT_PASSWORD, PREFIX_SECURITY);

 } catch (Exception e) {
 throw new RuntimeException("Error on wsSecurityHandler: " + e.getMessage());


 return true;

 public void close(MessageContext context) {
 // TODO Auto-generated method stub

 public boolean handleFault(SOAPMessageContext context) {
 // TODO Auto-generated method stub
 return true;

 public Set<QName> getHeaders() {
 // TODO Auto-generated method stub
 return null;

Xml Request: This is the payload request that Java Client request to the server.

<soapenv:Envelope xmlns:soapenv="">
 <wsse:Security xmlns:wsse="">
 <wsse:Password Type="">myPassword</wsse:Password>

Working with Expiration Human Task on Oracle Soa Suite 11g


I had that to implement an expiration process and go to leave the main steps here:

1- Creating a new Application: File -> New -> Generic Application -> ApplicationExpirationHT
2- Adding a project to application: Project Name: ProjectExpirationHT Project Type: SOA
3- Select: Empty Composite and click at Finish
4- Make a drag and drop of BPEL Process to your composite.xml screen PS: Choose One Way BPEL Process on template combobox
5- Go to file BPELProcess1.bpel in design mode and drag and drop a Human Task Component
6-Double Click in the green human task icon, click at the green plus button
7-Add a Task parameter, for this example i will make the default input parameter (string), that i will use to set the time of expiration (on duration format)
8-Here goes the magic point; Add the custom outcome action called “EXPIRED”
9-This is the final configuration screen. Your screen should like this:
10-Edit your Humantask1.task file and add an user assignment (weblogic is the default user)
11-This is the main configuration for the task expiration (Deadlines): Check “Expire After” and select the task parameter that exists in your payload variable, for this example is inputstring (/task:task/task:payload/task:Parameter1)
12-This is the final step, when your task expires, will be enter on Expired branch and you could make other things when the task expires
Important Tips-

  1. Your payload parameter should be in a DURATION Format, here is an example (P0Y0M0DT0H0M0S). Here is more details about this default type:
  2. When you set the Deadlines on your .task file, the expression for duration should be a parameter of your payload, because the rest of task parameters is READ-ONLY
  3. If your bpel is already created and you want to add the expiration validation, don’t worry, you cannot to recreate all flow, it is enough to add a new branch, copy of the others outcomes expressions and change the status task to EXPIRED, it works !
That is it people, if have any question, invite a email for me or better, add commentary for this post and i can help you !

How to capture the Task programmatically through Managed Bean (Adf – Soa Suite – Human Task)


This is another useful code that lets you to capture the task with full attributes from your Java Class (Managed Bean).


public TaskImpl getCurrentTaskFromWorkflow() throws WorkflowException {
    TaskImpl task = null;
    Map parameters=AdfFacesContext.getCurrentInstance().getPageFlowScope();
    IWorkflowServiceClient wfSvcClient = WorkflowService.getWorkflowServiceClient();
    ITaskQueryService queryService = wfSvcClient.getTaskQueryService();
    String contextId = (String)parameters.get("bpmWorklistContext");
    IWorkflowContext context = queryService.getWorkflowContext(contextId);
    String taskId = (String)parameters.get("bpmWorklistTaskId");
    String strTaskVersion = (String)parameters.get("bpmWorklistTaskVersion");
    if(taskId != null){
        int taskVersion = 0;
        if(strTaskVersion != null && !strTaskVersion.trim().equals("")){
                taskVersion = Integer.parseInt(strTaskVersion);
            } catch(NumberFormatException exc){
                taskVersion = 1;
        if(taskVersion == 0){
            task = (TaskImpl)queryService.getTaskDetailsById(context, taskId);
            task = (TaskImpl)queryService.getTaskVersionDetails(context, taskId, taskVersion);
    return task;

How to capture programmatically (Java – Adf Faces) an attribute from payload task (Human Task Form)

Hi Guys,

This is an useful code that capture the value of an attribute inside of payload from Human Task generated automatically from bpel.

Here is a list of attributes that exists in your human task form.

With this code, you can capture the value of any attribute.

You can to call this method this way: getValueAttributeFromHumanTask(“numeroPedido”)

import oracle.adf.model.BindingContext;
import oracle.binding.AttributeBinding;
import oracle.binding.BindingContainer;

public String getValueAttributeFromHumanTask(String attributeName){
    String response = "";
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    AttributeBinding attr = (AttributeBinding)bindings.getControlBinding(attributeName);
    DataObject data = null;
    if(attr != null){
        data = (DataObject)attr.getInputValue();
    if(data != null){
        response = data.getValue();
    return response;

Capturing Soap Message through Http Traffic (Web Services)


In this post i will to learn how to capture the Soap traffic communication of a Web Service.

I will cover two tools for this:

Suppose that i have my webservice running in this endpoint:

Solution 1) Using WireShark:

WireShark is a tool for capture packets from network where the computer is on. We will use this tool for capture our http packet with soap message.
For download this tool access here:

If you are in a Debian Linux just make it: sudo apt-get install wireshark

Obs.: In linux you should execute the wireshark as “sudo wireshark” for access the network.

Step 1) Install Wireshark
Step 2) Open wireshark and go to: Edit -> Preferences -> Protocols -> HTTP and put your port at TCP Ports. In our example is 9876. Click at OK
Step 3) Go to Capture -> Interfaces -> Click at Options in your correct network adapter -> And fill as below:

Just type the filter “xml” at filter box and click at Apply:

Right now, you shouls invoke the Web Service through your favorite Client. (SoapUI for example, or from your software, java, python, ruby and etc …)

Finally, you will see the two packet http (Request and Response):

You can see many informations such as packet size, your soap envelope and many many others.

Observation: Using WireShark you need to use the ip, not use localhost or because wireshark read the traffic when the message to come from other machine. So your client should be in other physical machine or other Virtual Machine works too

Solution 2: Using Apache TCPMON tool

The apache tcpmon is a tool that works like a proxy, your endpoint in your client should point to tcpmon and tcpmon point to your real webservice.

This tool is available here:

This is a tutorial for how to use it:

Observation: This tool works with localhost and

That is it. There is a lots of tool for capture packets and traffic Soa. These two is the most used for this proposit.

Victor Jabur.