Sunday, April 12, 2015

ADF BC Web Service - Return List of Complex Types

ADF Business Components can be exposed as SOAP Services. Application Module provides Service Interfaces as a way to define operations for the services to be exposed. Custom methods written in AMImpl class can also be exposed as operation of web services.

But one of the limitation is that there is restriction on return types from the services exposed as service interface from Application Module.

In this post we will see how easily we can develop a web service using ADF BC Service Interface and can tweak/use one of the given returnType List<ViewRowImpl>  to return list of complex type object.

Use case here is to create an operation in ApplicationModuleImpl class to return List of Object consiting of three variables -  DepartmentName,ManagerId,IsManagerFlag and expose the operation as ADF BC Service Interface SOAP Service. (Jdeveloper 11.1.1.7)


So Lets get started

Created a simple ADF Web Application using HR Schema and created DepartmentsEO , VO and AM and there respective Java Classes.

Create a Programmatic VO - WSResultPVO which will be returned from the operation of the WebService.





Now Add three variables in the PVO. DepartmentName,ManagerId and IsManagerFlag. 



Generate Necessary VOImpl and RowImp classes and set datatypes for the variables.

Remember to make these variables set AlwaysUpdatable as below.




Do a next and finish.

Now write a method in AMImpl class which has a code below. This method is an operation of the Web Service which will return the List of Complex type.




As clear from the code, the rows of WSResultPVO is being set programmatically. DepartmentsVO is iterated and value of DepartmentName and ManagerId is fetched and set into the rows of WSResultPVO. IsManagerFlag is being set Y here which can be changed based on any logic in real time use cases. 

At last the WSResultPVO row is added to the List - returnList which is being returned by the operation method.

We are all done with code part. Now lets quickly create service interface and expose the web service.

Go to Service Interface tab of AM. Click on Green Add Icon.


Here you can define the service name. We will go with default for this example.



On Next screen just shuttle the method which we need to expose and which is there in AMImpl class.



We need to define what will be the return type from the operation. So expand the shuttled method and click java.util.List and select WSResultPVO from below as shown below.




Do next and finish. Below will be added to Service Interface.




Thats it we are done now. Just Run the newly generated serviceImpl class from serviceInterface.


After running, there will be link of the exposed service and one can test it. Just click the operation and below shown will be the results.




So by using ViewRowImpl, we can return List of complex type object which can carter requirement of having complex type returned from the service.

Thanks






21 comments:

  1. Good to know that! Do you know if its possible to work with this List in Oracle MAF? I have a requirement to create a Web Service to return a complex list and show on my Mobile Application.
    Thank you.

    ReplyDelete
  2. Thanks Rohan.
    It is a very useful for exposing complex type (Return type )webservice !!!!
    waiting for more useful POC's

    ReplyDelete
  3. A very good and informative article indeed. It helps me a lot to enhance my knowledge. Keep sharing in future.I will be waiting for your next blog.
    latest technologies in computer

    ReplyDelete
  4. Hi Rohan,
    Thanks for nice blog.
    I have a scenario where I want to return Master-Detail data as Complex Return Type.
    Can you help me on this on How to achive this?

    Regards,
    Kaustubh Patel.

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. This comment has been removed by the author.

      Delete
  5. This article provide excellent information. I really like it and understand many things from here this page, Professional web app developer USA

    ReplyDelete
  6. This blog is so nice to me. I will keep on here again and again. Visit my link as well..
    SEO services pakistan

    ReplyDelete
  7. Hello, I tried but I get the following error, I use ADF 10.3g
    serialization error: no serializer is registered for(class xxx.xxx.xxx,null) serialization error:

    ReplyDelete
  8. "Great blog created by you. I read your blog, its best and useful information. You have done a great work. Super blogging and keep it up.php jobs in hyderabad.
    "

    ReplyDelete
  9. Great blog you have written for us Thanks for sharing good content keep sharing... check it once through MSBI Online Training for more information on microsoft.

    ReplyDelete
  10. hi
    what type of deployment(eg JAR ,SAR,WAR) could i deploy for this application, so i can reuse this web service in other applications

    ReplyDelete
  11. • Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online Training HYDERABAD

    ReplyDelete
  12. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking
    Internet Marketing Companies Bangalore
    Digital Marketing Company Bangalore
    Best SEO Services in Bangalore

    ReplyDelete
  13. Good article , everybody like this, You are so awesome! I don’t suppose I’ve truly read through a
    single thing like this before. So wonderful to find somebody
    with some original thoughts on this topic. Seriously.. thank
    you for starting this up. This website is one thing that is required on the web, someone with a little originality!

    ReplyDelete
  14. Nice information that you have shared with us. It's and interesting blog. Thanks for sharing nice information. Here I also want to share a site London web design and it will be beneficial for others.

    ReplyDelete
  15. Wow it is really wonderful and awesome thus it is veWow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your site.ry much useful for me to understand many concepts and helped me a lot.
    Best Oracle ADF Course in Bangalore

    ReplyDelete