Saturday, August 1, 2009

Web Service Interface for ADF BC Application Module in Oracle Fusion 11g

I'm starting series of posts where I will describe how you can orchestrate and connect various services in your infrastructure with Oracle Fusion/SOA 11g. I will follow such plan during my infrastructure implementation:
  • Will create Web Service interface for Application Module and expose custom methods
  • Will create second application, where will raise Business Event
  • Will create BPEL composite, this composite will be subscribed to raised event and will route process according Human Task outcome
Today I will cover first step from my plan and will define Web Service interface for custom methods based on ADF BC Application Module. You can download sample application and deploy it in your standalone Oracle WebLogic environment - SalaryControlService.zip.

Let's describe application structure, Web Service deployment and test process in Oracle Fusion 11g. You can find additional info on this topic in Oracle Fusion 11g Developer Guide - Integrating Service-Enabled Application Modules.

First, developed application contains two custom methods developed in Application Module implementation class - updateSalary and emplWorkLoad. I have exposed them through Client Interface as custom Java methods in order to test easier in ADF Business Components Browser utility:


Methods are pretty simple:


updateSalary method gets specific row by its Id and updates Salary attribute with provided value. emplWorkLoad method executes read-only View Object with Bind Variable and gets summarized information for employee workload. Read-only View Object implements query statement with grouping and MONTHS_BETWEEN function:


Oracle ADF allows to generate access through Web Service not only to custom methods, but to Application Module data model itself, however I prefer to access custom methods. Service Interface for two custom methods access through Web Service is defined:


In Application Navigator you can see that Web Service artifacts are generated by JDeveloper 11g:


  • Remote common interface - HrModuleService.java
  • Remote service schema - HrModuleService.xsd
  • Remote service definition - HrModuleService.wsdl
  • Remote service class - HrModuleServiceImpl.java
Now we can simply deploy Application Module exposed through Web Service to Oracle WebLogic and test it. In order to do this, in your Model project define deployment profile for Business Components Service Interface:


In Application deployment profile verify that Model profile is used:


When prerequisite steps are done, deploy application directly from JDeveloper 11g to WebLogic server. After deployment is finished successfully, you can open Oracle Enterprise Manager console and monitor deployed Web Service performance:


From Web Services section box, you can invoke Test functionality - Test Web Service screen will be opened:


Let's test now emplWorkLoad method, provide value for employeeId input argument and press Test Web Service button:


Response is generated and we can see successful Web Service execution result:


Now let's test second method - updateSalary:


Provide values for input arguments:


Invoke Web Service test, result should be successful:


Employee (Id = 101), Salary attribute value is updated correctly:

39 comments:

watson said...

I have seen your Blog... It’s too informative. There are many posts which are really too Good and very useful.

praphulla said...

Hi,
Can you show the steps for jdeveloper 10g, i am using 10.1.3.3 as an IDE.

Unknown said...

First of all, I would like to convey my thanks for such nice postings which are of really great help.

While deploying application (Service Enabled AM) to weblogic server 1033 I am always getting the error below. But running it in the integrated wls server and then accesing the service interface url in a browser, works absolutely fine. Could you please help....
***********
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
Error processing annotations: ..
[04:48:57 PM] Weblogic Server Exception: weblogic.application.ModuleException: Exception preparing module: EJBModule(ServiceInterfaceModel_MiddleTier.jar)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
Error processing annotations: .
[04:48:57 PM] Caused by: weblogic.utils.ErrorCollectionException:

There are 1 nested errors:

weblogic.j2ee.dd.xml.AnnotationProcessException: [EJB:015001]Unable to link class qct.oracle.model.server.serviceinterface.ServiceInterfaceAMServiceImpl in Jar C:\Oracle\MiddlewareWeblogic\user_projects\domains\rdr_domain1\servers\AdminServer\tmp\_WL_user\ServiceInterfaceModel\c1h9zc\ServiceInterfaceModel_MiddleTier.jar : java.lang.NoClassDefFoundError: qct/oracle/model/common/serviceinterface/ServiceInterfaceAMService
[04:48:57 PM] See server logs or server console for more details.
[04:48:57 PM] weblogic.application.ModuleException: Exception preparing module: EJBModule(ServiceInterfaceModel_MiddleTier.jar)
[EJB:011023]An error occurred while reading the deployment descriptor. The error was:
Error processing annotations: .
[04:48:57 PM] #### Deployment incomplete. ####
************************

Andrej Baranovskij said...

Have you installed 11g PS2 Fusion on standalone WLS?

Andrejus

Unknown said...

I have the latest WebLogic Server 11g Rel 1 (10.3.3) from the url http://www.oracle.com/technology/software/products/middleware/index.html
Infact I installed it just a week ago.
Then I have installed the ADF 1113 runtime to weblogic server.
Is it a seperate patchset you are referring to?
Also, for web services deployment, do I need to install SOA Suite to my weblogic server. If yes, could you kindly let me know the specific details of the patches to be applied.
*NOTE: I am using weblogic server windows version

Andrej Baranovskij said...

I was running it on standalone WebLogic instance with SOA.

You should install SOA and test. On WLS 10.3.3, you will need to install SOA PS1 and then apply SOA PS2 patch. There are no specific details, just follow install instructions.

Regards,
Andrejus

Unknown said...

After Installing PS2 to Weblogic server in Windows, I am still getting the error described above. Could you please help.
Thanks

Anonymous said...

Hi Andrejus,

What is the best approach, to call webservices? To generate Webservice interface through wsdl or creating webservice proxy through wsdl.

If i create a webservice proxy using wsdl, which project is the best place to put in the related files of webservice(Model or UI)

Kiran said...

hi i tried to deploye the app given by you but i was showing me following error,
Target URL -- http://localhost:7101/SalaryControlService/HrModuleService
Serializer initialization failed. Unable to define SDO data types.
java.net.URISyntaxException: Illegal character in path at index 18: file:/C:/Documents and Settings/KiranP/Application Data/JDeveloper/system11.1.1.3.37.56.60/o.j2ee/drs/SalaryControlService/ModelEJB.jar/lt/andrejusb/model/common/serviceinterface/HrModuleService.xsd
at java.net.URI$Parser.fail(URI.java:2809)
at java.net.URI$Parser.checkChars(URI.java:2982)
at at java.net.URL.toURI(URL.java:918)
at oracle.j2ee.ws.common.sdo.SDOHelper.getSchemas(SDOHelper.java:109)
at oracle.j2ee.ws.common.sdo.SDOHelper.defineSchemas(SDOHelper.java:76)
at oracle.j2ee.ws.common.databinding.runtime.sdo.SDOSerializerFactory.init(SDOSerializerFactory.java:56)
at oracle.j2ee.ws.common.databinding.runtime.spi.SerializerFactory.newInstance(SerializerFactory.java:44)
at oracle.j2ee.ws.common.jaxws.runtime.ServiceEndpointRuntimeMetadata.createSerializerFactory(ServiceEndpointRuntimeMetadata.java:122)
at oracle.j2ee.ws.common.jaxws.runtime.SoapInvocationSerializer.init(SoapInvocationSerializer.java:66)
at oracle.j2ee.ws.common.jaxws.runtime.SoapSerializerManager.getSerializer(SoapSerializerManager.java:54)
at oracle.j2ee.ws.server.jaxws.SoapEndpointSerializerManager.getSerializer(SoapEndpointSerializerManager.java:51)
at oracle.j2ee.ws.server.jaxws.ServiceEndpointRuntime.processMessage(ServiceEndpointRuntime.java:268)
at oracle.j2ee.ws.server.jaxws.ServiceEndpointRuntime.processMessage(ServiceEndpointRuntime.java:161)
at oracle.j2ee.ws.server.jaxws.JAXWSRuntimeDelegate.processMessage(JAXWSRuntimeDelegate.java:428)
at oracle.j2ee.ws.server.provider.ProviderProcessor.doEndpointProcessing(ProviderProcessor.java:1168)
at oracle.j2ee.ws.server.WebServiceProcessor.invokeEndpointImplementation(WebServiceProcessor.java:996)
at oracle.j2ee.ws.server.provider.ProviderProcessor.doRequestProcessing(ProviderProcessor.java:562)
at oracle.j2ee.ws.server.WebServiceProcessor.processRequest(WebServiceProcessor.java:222)
at oracle.(WebServiceServlet.java:430)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at )
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.doIt(WebAppServletContext.java:3684)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3650)
at .securedExecute(WebAppServletContext.java:2268)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2174)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1446)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
[EL Warning]: 2010-09-21 20:24:36.156--SDOUtil: Generated Type [ChangeSummary] conflicts with SDO specification naming rules for [ChangeSummary] and should be renamed.

i am not able to figure out the root cause of this error please help me out thanks kiran.

Unknown said...

Dear Andrejus,

Thanks for the informative article. I am trying to expose one custom method within my application module as web service and i am getting this error while deploying in Jdeveloper 11.1.1.3 version. Not able to figure out the reason. Any help or pointer would be highly appreciated.

Sachin said...

Dear Andrejus,
I am getting this error while deploying in Jdeveloper 11.1.1.3. Any help.pointer would be highly appreciated. I have exposed one of the Application module method to Web Service (as you have explained).


[03:15:10 PM] Deploying 4 profiles...
[03:15:11 PM] Wrote Web Application Module to C:\Documents and Settings\sacggupt\Application Data\JDeveloper\system11.1.1.3.37.56.60\o.j2ee\drs\MicroApplications\VendorEJB.war
[03:15:12 PM] Wrote EJB Module to C:\Documents and Settings\sacggupt\Application Data\JDeveloper\system11.1.1.3.37.56.60\o.j2ee\drs\MicroApplications\VendorEJB.jar
[03:15:13 PM] Wrote Web Application Module to C:\Documents and Settings\sacggupt\Application Data\JDeveloper\system11.1.1.3.37.56.60\o.j2ee\drs\MicroApplications\CommonWebApp.war
[03:15:13 PM] removed bundleresolver.jar from lib because it cannot be part of an EJB deployment
[03:15:14 PM] Wrote Enterprise Application Module to C:\Documents and Settings\sacggupt\Application Data\JDeveloper\system11.1.1.3.37.56.60\o.j2ee\drs\MicroApplications
[03:15:15 PM] java.lang.NullPointerException
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.jaxws.AssemblerProcessor.getClassNamesFromEjb(AssemblerProcessor.java:180)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.jaxws.AssemblerProcessor.processEjb(AssemblerProcessor.java:149)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.jaxws.JaxwsEjbAssembler.processEjb(JaxwsEjbAssembler.java:182)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.jaxws.JaxwsEjbAssembler.ejbAssemble(JaxwsEjbAssembler.java:152)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.cli.Processor.jaxwsEjbAssemble(Processor.java:630)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.cli.Processor.execute(Processor.java:327)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.cli.Processor.execute(Processor.java:230)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.Main.mainNoSystemExit(Main.java:84)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.Main.main(Main.java:49)
[03:15:15 PM] WARNING: Error while processing ejb-jar.xml for ejb module at "C:\Documents and Settings\sacggupt\Application Data\JDeveloper\system11.1.1.3.37.56.60\o.j2ee\drs\MicroApplications\VendorEJB.jar".
[03:15:15 PM] INFO: Unable to load annotation javax.interceptor.Interceptors for parsing. The annotation is ignored.
[03:15:15 PM] INFO: Unable to load annotation javax.interceptor.Interceptors for parsing. The annotation is ignored.
[03:15:15 PM] INFO: GenericWSWarAnnotationListener.parseAnnotatedClass Adding Servlet Mapping with URL pattern /UpdateVendorService for annotated WebService class oracle.retail.microapps.vendor.update.am.server.serviceinterface.UpdateVendorServiceImpl
[03:15:16 PM] WSA process exited with code 0
[03:15:16 PM] Deploying Application...

Failed to register the web service Config MBeans for application: MicroApplications endpoint: MicroAppTemplate-Vendor-context-root the error is: oracle.as.jmx.framework.util.MissingConfigurationFileException: The configuration at URI "WEB-INF\oracle-webservices.xml" cannot be loaded.
[03:15:33 PM] Application Deployed Successfully.
[03:15:33 PM] The following URL context root(s) were defined and can be used as a starting point to test your application:
[03:15:33 PM] http://10.176.162.5:7101/MicroApps-Common-context-root
[03:15:33 PM] http://10.176.162.5:7101/MicroAppTemplate-Vendor-context-root
[03:15:33 PM] Elapsed time for deployment: 24 seconds
[03:15:33 PM] ---- Deployment finished. ----
Run startup time: 23625 ms.
[Application MicroApplications deployed to Server Instance IntegratedWebLogicServer]

Target URL -- http://localhost:7101/MicroAppTemplate-Vendor-context-root/UpdateVendorService

Sachin said...

Dear Andrejus,

Thanks for the informative article. I am trying to expose one custom method within my application module as web service and i am getting this error while deploying in Jdeveloper 11.1.1.3 version. Not able to figure out the reason. Any help or pointer would be highly appreciated.


[03:15:15 PM] java.lang.NullPointerException
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.jaxws.AssemblerProcessor.getClassNamesFromEjb(AssemblerProcessor.java:180)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.jaxws.AssemblerProcessor.processEjb(AssemblerProcessor.java:149)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.jaxws.JaxwsEjbAssembler.processEjb(JaxwsEjbAssembler.java:182)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.jaxws.JaxwsEjbAssembler.ejbAssemble(JaxwsEjbAssembler.java:152)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.cli.Processor.jaxwsEjbAssemble(Processor.java:630)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.cli.Processor.execute(Processor.java:327)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.cli.Processor.execute(Processor.java:230)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.Main.mainNoSystemExit(Main.java:84)
[03:15:15 PM] at oracle.j2ee.ws.tools.wsa.Main.main(Main.java:49)
[03:15:15 PM] WARNING: Error while processing ejb-jar.xml for ejb module at "C:\Documents and Settings\sacggupt\Application Data\JDeveloper\system11.1.1.3.37.56.60\o.j2ee\drs\MicroApplications\VendorEJB.jar".
[03:15:15 PM] INFO: Unable to load annotation javax.interceptor.Interceptors for parsing. The annotation is ignored.
[03:15:15 PM] INFO: Unable to load annotation javax.interceptor.Interceptors for parsing. The annotation is ignored.

Andrej Baranovskij said...

Hi,

I will need to test it on latest WLS, will inform you then, if I will be able to reproduce.

Thanks,
Andrejus

Anonymous said...

Hi,

If we expose an application module as webservices, will this web services have the same authentication that we have defined for the application?

Andrej Baranovskij said...

Hi,

ADF Security will not be applied to WS, you need to secure WS separately.

Andrejus

Sashika said...

Ok Nice, then we need Oracle web services manager to define the security policy for AppModule Webservices(according to documentation B31974-05 section 11.2.13). So need to license Oracle SOA suite cos webservices manager comes under SOA suite.

Andrej Baranovskij said...

Yes, nice reason to get SOA Suite ;)

Andrejus

Anonymous said...

Hi Andrejus,

Thanks for the awesome tutorials!

Unfortunately I am running into an error.

I am using JDEV 11.1.1.4 and when I try to deploy using the deployment descriptor I created, I get the following error:

Error: Could not load endpointInterface

This occurs when I 'Deploy to Ear' so I don't think its related to my WLS. Do you know what could be causing this?

Andrej Baranovskij said...

Yes, it might be deployment configuration files changes with new release. Just follow steps and recreate your sample app.

Andrejus

Maiko Rocha said...

The error is because you're selection _both_ Common _and_ Middle Tier. For server-side deployment of the service you only need Middle Tier, which is the only one selected by default.

Andrej Baranovskij said...

Thanks for update Maiko.

Andrejus

Mehdi Mohammadi said...

Hi Andrejus
Do you know how can I override default base operations on Application Module Interfaces (eg create) I want doing some operation after that I have posted my record .
How can I write Custom operation by using built in create(SDO Objact) functionality ?

Anonymous said...

Hi, i need invoke the methods published, custom methods and methods of the views, how can i invoke them from a stand alone application client, i need an example of the code to invoke to the EJB, how do i know the name of EJB to call it

ಆಶ್ವಿನ್ ಆಲ್ಮೆಡ (Ashwin Almeida) said...

Hi Andrejus,

Is there a way to access the method's in service interface directly from an java class. like in a managed bean if the projects (View an Model) are in same application.

Andrej Baranovskij said...

Yes, you can generate Web Service proxy.

Andrejus

Verma said...

I had a similar implementation but I generated asynchronous methods in the service interface.

When I checked the deployed application in the weblogic console, I found two MDBs generated automatically to handle the asynchronous request and response in my application.

I am trying to set some properties to these MDBs like initial-beans-in-free-pool etc. in the weblogic-ejb-jar.xml deployment file but to no avail.

Can you please give me any information on how to customize number of initial beans for these MDBs?

SD said...

Please let me know if this BC web service is transaction enabled
If not how this can be achieved ?

Regards
SD

Andrej Baranovskij said...

Yes, it can be transaction enabled, because its based on Application Module.

Andrejus

oceans said...

Hi Andrejus,

Thanks for a good tip up there,
Can you tell me a way to do the same using RESTful web service to give the response as JASON object.

Regards,
Oceanvijai

Anonymous said...

Andrejus,

I created an proxy for webservice which is secured.

Is there any way to pass username/Password while invoking the web service through proxy?

Thanks,
ChaiV

Charles Prabhu said...

Please help.....

Keven Chan said...

Hi,

First of all, thanks for the simple but direct example, it really helps.

Question:
I tried to create a method with my customed object - public String presistQuoteHeader(QuoteHeaderSDO quoteHeader){} and it complains

Business Components: Method "presistQuoteHeader(CaeApprQuoteHeaderViewSDO):String" cannot be exposed via service interface because parameter type "com.oracle.cae.model.service.common.QuoteHeaderSDO QuoteHeaderSDO " is not supported

I know that from this - https://forums.oracle.com/forums/thread.jspa?messageID=10347645

it only support primitive Java type, oracle.jbo.server.ViewRowImpl, java.util.List, oracle.jbo.AttributeList, or java.util.List.

But do you know how to get around this issue? Thanks and any help is appreciated!

KUNWAR said...

We are trying to Consume Web Service in our SOA Application and we are getting the following error:-

"java.lang.Exception: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: oracle.fabric.common.FabricInvocationException: Unable to access the following endpoint(s): http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/yyyyyyy.svc ".

Scenario:-

1.The Web Service that we are trying to consume is built on Microsoft Dynamics AX Framework and is using Windows Authentication and we are using Oracle Soa Suite 11g(11.1.1.5) to access it.
2.The Web Serice is Hosted on IIS server 7.0 . The Soa server and IIS server both are on the same domain(Also need to confirm that is there any need to pass credentials while consuming Web Services when both the servers are on same domain??).
3.We have tested the Web Service in SOAP UI and is working fine only when we pass the Username,Password and Domain.And if we do not pass the User Credentials then we get the following error:-
" 401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied."

4.We can even access the WSDL from the browser.

Plz help me out to resolve this issue.Will be really greatfull

satya said...

Hi Andrejus,

I am trying to invoke an application module method asynchronously. As part of this I have created service interface methods and generated a wsdl on this application module with asynchronous methods. My question is can I call the asynchronous methods of the wsdl from the same application module. Even I tried calling the async method from another application module, but its throwing exception - Unexpected exception
java.lang.NullPointerException
at oracle.jbo.server.svc.ServiceImpl.acquireResources(ServiceImpl.java:384). The sample code I used is

TestAppModuleServiceImpl impl = new TestAppModuleServiceImpl();
StringResult str = impl.getHelloAsync();
Please let me know I going in right direction.

Thanks,
Satya

satya said...

I am using jDeveloper 11.1.1.5.

Thanks,
Satya

sree said...

thank you

Don Kleppinger said...

Does this get the AM from the ADF AM pool or does it instantiate a new AM instance each time? Also curious how to set up security. I got a stand alone example to work but it completely broke my ADF application when I tried to add a service enabled application module to it. It got class loader errors trying to load existing app modules.

Andrej Baranovskij said...

Hi,

When you define WS for AM, it creates new AM configuration, it is using AM pool as well.

For secured WS you can check this post - http://andrejusb.blogspot.com/2012/11/adf-mobile-secured-web-service-access.html This is about ADF Mobile, but Web Service part is about secured AM Web Service.

Andrejus

Alfredo Rodríguez said...

Hi Andrejus, thanks! but I have a problem, I've continued your steps but when I write wsdl in a browser i get the message "WSDLException: faultCode=OTHER_ERROR: A policy advertisement error occurred while retrieving the WSDL associated with the provider: JDEServicesAMServiceSoapHttpPort: oracle.fabric.common.AdvertisementException: Advertisement Engine failure"

what is it the problem? If I run on local I can test webservices without problem.

Thanks