Posts tagged XML

Business Validation in Oracle SOA Suite 11g using Schematron

In a previous post I’ve explained the Schematron standard, how it works and how to use it. In the Oracle SOA Suite you can ‘Validate Semantic’ on the input (request) of a routing rule in a Mediator component by selecting a Schematron file. This is the Schemtron xml file in which you define your validation rules. The SOA Suite takes care of applying them on the request by executing the double transformation.
However, to be able to get the Schematron file working you need to declare the namespaces of the input message and rewrite a report rule to an assert rule. In this post I will show you how to do this with the same business rules (so the same Schematron rules and Schematron file) as the last example in a previous blog explaining Schematron.
Read the rest of this entry »

Absolutely Typical – The whole story on Types and how they power PL/SQL Interoperability (UKOUG, 2011)

This presentation will hopefully convince database developers that types in the Oracle Database are worth their salt – and more. With the recent improvements in 11gR2, the pieces are available to complete the puzzle of structured and modern programming with a touch of OO and more importantly to create a decoupled, reusable API that exposes services based on tables and views to clients that speak SQL, AQ, PL/SQL, Types, XML or RESTful, through SQL*Net, JDBC or HTTP.

This session shows through many demonstrations how types and collections are defined, how they are used between SQL and PL/SQL and how they can be converted to and from XML and JSON and how they drive Native WebServices as well as RESTful services based on the Embedded PL/SQL Gateway. Everyone doing PL/SQL programming will benefit immediately from this session. Every Database Developer should be aware of Types and Collections. For structured programming, for optimal SQL to PL/SQL integration and for interoperability to client application. This session introduces Types and Collections, their OO capabilities, the conversion to XML and JSON, their use in Native and RESTful WebServices and the pivotal role they can play in encapsulation and decoupling.

The slides can be reviewed here:

Resources

Download Slides plus Demoscripts here: AbsolutelyTypical_UKOUG2011_jellema.zip.

Generate IDs in all components in ADF Faces pages and fragments – to facilitate automated Selenium based testing

Lately, we have been introducing Selenium based testing for many our ADF Faces based web applications. Or rather, our testers created the tests for the web pages using Selenium. And did so quite successfully.

However, certain test scripts seemed to fall apart after having been run only a few times. That was rather annoying. Upon closer inspection, we noticed that the scripts that started failing had one thing in common: the Selenium scripts contained references to element id values that started with j_id. I realized that these id values are not defined in the pages by the developer, but instead assigned at run time by the ADF Faces framework. That in turn means that these ID values can easily change, between two test sessions using the same test script for example.

In order to have test scripts that continue functioning – it was required to have fixed id values. Besides, it is a best practice to assign id values to all components at design time rather than having them generated dynamically. Unfortunately, as found out later, we had over 2000 components lacking an id attribute with developer defined value. Going through all files and assigning ID values manually was not a task anyone on the team was really looking forward to.

We then decided to write a small Java utility that processes all JSPX and JSFF files, locates elements of specified types without and ID attribute and assigns a unique ID attribute value. Running this utility took all of 45 seconds and corrected 2186 components.

Read the rest of this entry »

How to call a webservice directly from Java (without webservice library)

In this blog I will show you how you can call a webservice programmatically in Java without using a webservice library like JAX-WS or Apache Axis. Normally you would use of course a webservice library, but in some cases this can be useful and quick; for example when you have problems generating a client proxy with a webservice library or if you only need some small specific parts of the SOAP response XML tree.  It shows that a SOAP call is just XML over HTTP, from a plain piece of Java code. Then, I will show you an example how you can use this and make your own servlet webservice-tester like a simple SoapUI in JDeveloper 11.1.1.3.

Read the rest of this entry »

Turning any XML document into a Java Object graph using JAXB 2.0

As a followup to my recent article on how to Produce and XML document based on data in a POJO structure using JAXB (http://technology.amis.nl/blog/12499/creating-an-xml-document-based-on-my-pojo-domain-model-how-will-jaxb-help-me) I will describe in this article how to go the reverse route: how to take any XML document and process it into a Java Object graph. I will do that using JAXB.

The steps described in this article are:

  • create XSD based on the XML document that I want to turn into Java objects
  • generate a JAXB Java class structure based on the XSD
  • use JAXB to unmarshall the XML document from file or URL into the Java objects
  • retrieve information from the POJOs that are instantiated by the unmarshalling

The tool I use in this article is JDeveloper 11g. However, everything is based on standard technology and will work anywhere (except for the creation of the XSD based on an XML, that is a specific XML IDE feature).

Read the rest of this entry »

Creating an XML document based on my POJO domain model – how will JAXB help me?

The challenge is a common one. We have got data in a domain model, based on POJOs. And we need to marshall that data into an XML document. Note that the exact structure of that document is not so important – we will probably translate is somewhere anyway. At this point, all we have is a set of POJO definitions. There is no XSD, no predefined XML structure.

JAXB – the Java Architecture for XML Binding – seems like the technology to turn to. My experience with JAXB has mainly been from the other end: we have XML data, described by an XSD, that we want to turn into Java Objects (unmarshall XML to Java). In that case, we take the XSD that describes the XML, generate Java classes and use JAXB to unmarshall XML into objects based on those classes. The alternative round – taking classes and marshalling them into XML would be just as simple – or even simpler, now would it not?

Well, it was not as straightforward as I hoped it would be. I thought that adding a few JAXB annotations to my existing POJO model would do the trick – but no such luck. Unless I am completely misguided and mistaken, the steps required are:

  • create an XSD based on the original POJO model
  • generate JAXB annotated classes from that XSD schema (classes that very similar to but not exactly the same as the original POJOs)
  • use the JAXB ObjectFactory to create instances of the JAXB-POJOs (rather than simply new Object() or new Object(a,b,c) on the original POJOs)
  • use the JAXB Context and the generated ObjectFactory class to marshall the JAXB-POJO object graph into an XML document

The original POJO model is a very simple one: the Company class has a name property and an employees property – which is a List<Employee>.

Image

Here is a snippet of the XML document that we will produce:

Image

This article uses JDeveloper 11gR2 for demonstrating the steps with JAXB – however, the steps will be similar and the code exactly the same in other IDEs.

Read the rest of this entry »

How to remove unwanted SOAP header elements in JAX-WS

In our current webservice project with JAX-WS in  JDeveloper  11.1.1.3 we have a challenge with calling a webservice. This webservice from a remote organisation does not accept specific SOAP header elements our client application creates – although we followed the contract of the WSDL correctly. Of course this webservice must follow it as well as we have to, but for now we don’t have a choice but to make a workaround.  How can we remove unwanted elements from a SOAP header? In this blog I will show you how you can do that using a JAX-WS SOAPHandler that inspects the SOAP header and removes specific addressing elements. Read the rest of this entry »

Android puts Oracle on the (Google) map.

For a couple of months I have been discovering the Android platform. As an original Oracle developer I was wondering how an Android app can be connected to an Oracle database.
For this purpose I developed an Android app that stores speed traps that users may hit while driving, into an Oracle database. The app also retrieves these speed traps from the database and draws them onto a Google map:

Fig. 1 After pressing the Android device’s menu button, two menu options ‘Retrieve’ and ‘Report’ (speed traps) appear.

Fig. 1 After pressing the Android device’s menu button, two menu options ‘Retrieve’ and ‘Report’ (speed traps) appear.

Fig. 2 After pressing the ‘Retrieve’ option all speed traps already stored in the database appear as markers on the map.

Fig. 2 After pressing the ‘Retrieve’ option all speed traps already stored in the database appear as markers on the map.

Read the rest of this entry »

Ways to instantiate a variable in Oracle Service Bus based on a static XML document

Today we had an interesting exploration into the many ways available in the Oracle Service Bus to load a piece of XML into a variable in a message flow – to use as the source for populating part of a to-be-forwarded request message to the business service or for enriching the response message. Even such a seemingly straightforward task turned out to have a number of ways to approach, each with their own merits and complexities.

The various approaches we uncovered in a space of ten minutes or so:

  • use a static expression in an Assign action, simply copying the XML content into the variable
  • use the function fn:doc that can load XML from a local file and assign the XML to a variable that way
  • introduce the file adapter to load the XML file from the local file system and assign it to a variable; this would also support non-XML formats – like comma separated values – that can be converted to XML
  • use the database adapter (or the fn-bea:execute-sql) to retrieve the XML content from a relational database
  • store the XML content in an XQuery transformation
  • do any of the above and wrap it inside a Proxy Service that can be invoked from from other services, potentially governed by the service result cache

Considerations for choosing an approach definitely include the reusability (we do not want to define the same XML document in more than one location) and overhead (especially for parsing the XML). Solutions that cache the XML rather than load it every time a service instances has a need for it are definitely preferred.

It turns out that due to the stateless nature of the OSB the first four methods are not attractive in our situation – where we have very few changes in these static (!) XML documents and many instances of the services. The fifth approach, using the XQuery resource, is easily reusable across projects and services and has as an important bonus the fact the XQuery transformation templates are cached by the OSB, across the stateless instances of OSB Services.

Read the rest of this entry »

AMIS@OOW

Yesterday evening we had our annual Oracle Open World review at our office in Nieuwegein. Around eighty people attended and all were very involved with the session. Five AMIS employees were at Oracle Open World, and each one covered one area of interest.

Before dinner Lucas gave an overview of the trends and topics that were covered at Oracle Open World. Just to convey the sheer size of OOW, Peter illustrated this by facts (number of people attending, number of lunches served, etc) as well as by photos. I’m still very impressed that they covered a four lane street (Howard street) by a tent, just to serve lunch… amazing.

Marco and myself gave an overview of what AMIS was doing at OOW, as well as the Oracle ACE Directors briefing right before OOW started.

There were a number of goodies that we took from Oracle Open World to give away this evening. We decided to do it a little different this year, we organized a BuzzWord Bingo. Each of the attendees was given a bingo sheet with some of the buzzwords that would be covered during our presentations.

Before we went for dinner six people had bingo and got their goodies to take home.

This time we had a Mexican Style dinner, very lovely. Lots of discussion of the topics and trends covered in the first part of the evening.

After dinner the more technical details where covered. Starting with Marco who covered the new hardware as well as Oracle Linux and Oracle VM. Then it was my turn to tell about the Oracle Database, SQL Developer, SQL Developer Datamodeler and APEX.

Peter talked about the SOA Suite and Fusion Middleware. Aino had the last slot, and covered JavaOne.

Around 21:15 (9:15 PM) all session had finished, and the bar “Cafe@AMIS” was opened. About an hour later it was time to call it a night. All in all a very succesful, very informative evening.

Thank you all for coming to our “show” and hopefully we’ll do the same for Oracle Open World 2011.