Wednesday, August 31, 2011

How to call a Web Service Data Control with pre-populated search criteria

I'ld like to present you with the following challenge:

We have an interface between our ADF application to a back-end application (Siebel) via Middleware, based of Web Services.
Given the datamodel of Siebel, you can image the complexity of the Web Service.

When the Web Service is called, some input values must be supplied.
These values should not be entered by the end-user, but should be 'hidden' from the user and defined by the application (e.g. Calling Application) or defined by navigation (e.g. contact ID, customer ID etc)

All the instructions and posts we have found on integrating Web Services via Data Controls  basically describe the following:
 - Create a Data Control based on the Web Service
 - Create a JSF page
 - Drag one (or more) of the input parameters to the page (all that you need)
 - Drag the WebServiceMethodCall(Object) to the page as an ADF page 
 - Drag one (or more) of the response fields to the page

To illustrate the WebServiceMethodCall see this image:

When you run the page, the web service is called (without parameters) and the result is displayed on the page.
On the page, you can enter some search criteria, and press the button
Then the web service is called and the page displays the result.

Now the challenge is:
How do we pre-populate the search criteria, bases on some application scope value (application name) and some session scope value (contact id) and make sure that the first call to the web service is done with these values.

Any idea's are more then welcome.

Answer will be posted as soon as we have it...
The question is also posted on the OTN ADF / JDeveloper forum

Wednesday, August 24, 2011

local part cannot be "null" when creating a QName using Soap UI Mock Service

This week we fixed a major issue in our project.

We're building a support portal in Web Center for an international customer. The portal interfaces to a number of back office systems, like Siebel, eBusiness Suite etc.
These interfaces are serviced by IBM Web Sphere and the logic in the service bus has (of course) to be developed.
The development starts with the WSDL of the web service we need to call. Once this WSDL is defined, we can start building.
However, we need an actual web service to test our implementation.

We used Soap UI in the past to test web services. Amazingly Soap UI has a feature to create a mock service. Basically a stub web service, based upon a WSDL.
In this mock service, you can define the response that is sent back upon a request, so you can test your application with 'live' data.
With this mock service, we created a data control based on the web service in JDeveloper and added this to a page (pretty straight forward, see a number of blog posts regarding this topic)
However, when we run the page we get an error: local part cannot be "null" when creating a QName

What is going on???
We read a lot of posts, forum entries and even raised a Service Request at Oracle Support. No answer however in more then a week.
Since all generated code is xml, we can't debug properly to see what went wrong.

The WSDL and associated includes a lot of complex types. Is this causing the issue?
Will this work with a web service without complex input or output parameters?Also, we see six calls to the mock service in Soap UI (in the log section). Is this caused by some sort of retry mechanism?

To investigate, we built two separate web services, one with complex output and one without complex output.  When we created mock services in Soap UI, both resulted in the same error. Is there something wrong with the 'data control based on a web service' in ADF?
To test, we deployed the web services to an actual WebLogic Server.
When we call this web service from the application, we don't get an error!
So the mechanism works, but what goes wrong?

There is a potential issue in the headers. The mock service gzips the response. Also, the content type header value is set to test/xml, which 'should' be application/xml
Can it be ADF handles this incorrect (or not at all)??
With Soap UI we call the deployed web service to view the differences. Besides the fact that there are more header variables, the ones that also exist in the mock service header, have the same values.
Can it then be in the response itself???
The XML in the response seems the same. Only differences are namespaces and how the namespaces are defined, but that should not be a problem.
The response from the mock service also contains some comments to indicate which fields are optional and which sections can be repeated. But comments in XML is legal so this too should not be a problem...

But it is :(
We copied the response from the deplloyed web service to the mock service (the mock service response can be edited to return the data you want) and with the response copied from the deployed service, the call worked in ADF!
It took another 10 minutes to identify the comments to be the cause.

We're still not sure what goes wrong in the ADF application, but apparently one of the layers cannot handle comments in the response.
Edit the response to not include any comments. This will run the application smoothly.
Total Time Spent: Over a week.
Time Spent Next Time: None (thanks to this post ;)