By Asantaga-Oracle on Jun 13, 2014
Some of you may be using my RESTFacade which I wrote and Oracle recently released as sample code on OTN (link).
There has been a couple of requests, or more "how to"s which I thought Id post here.
- How to add CORS support (Cross Origin Resource Sharing) support
- How to use the facade with custom fields defined in AppComposer
How to add CORS support (Cross Origin Resource Sharing) support
Adding CORs support is quite straightforward, simply open the web.xml file in the FusionRESTService project and add the following <init-param>
How to use the facade with CustomFields
This one is a little trickier. The facade uses a collection of static proxies and although I am planning to rewrite the proxies as "dynamic" proxies we're not there yet (and I need to do some reading first).
The only way to use custom fields with the facade today is to regenerate the proxies against your Sales Cloud instance. Here I will go through the steps you will need to do, however in the near future I will release some "scripts" which will do it all for you.
1. Identify the correct package name
The Facade has all its proxies in projects called "FusionProxy_<Object>Service. Within this project you will find the java classes are split between two packages
- com.oracle.xmlns : This contains all the standard generated types
- oracle.demo.pts.fusionproxy.<objectName> : This one contains the proxy itself
Identify the full package name of the proxy for the object you are going to regenerate. In my example here, im going to regenerate the Opportunity object and as you can see the package name is oracle.demo.pts.fusionproxy.opportunities
2. Delete the contents of the proxy directory.
Shutdown JDeveloper, navigate to the source directory of the proxy project and delete both the src and classes
Startup JDeveloper, navigate to the FusionProxys project , in our case FusionProxy_OpportunityService, you should notice it is now "empty". If it is not the press the refresh button
4. Regenerate the proxy from scratch
- Select the project, right mouse click and select new...
- Select "Web Service proxy" from the Web Services Categories.. If it doesnt show try typing it in the search dialog
- Enter the appropriate WSDL Document. This is the Hostname of your service + Endpoint URL. You can get this information from the fusionconfig.properties file.
E.g. For opportunities it is https://<hostname>/opptyMgmtOpportunities/OpportunityService?wsdl
Hint: Check it works in a webbrowser first!
- Next, Wait a bit....
- For the package name, use the name you identified in step 1, for the Root Package leave it blank
- Un-Select "Generate As Async"
- Select "Don't generate any asynchronous methods"
- Select "Oracle/wss_username_token_over_ssl_client_policy"
- Next, then Finish
This will generate the proxy from scratch , just note the generation of the proxy may take some time.
5. Go to the XJS_Beans project
Within here edit the generateClasses script and modify dummy.oracle.com with your hostname for all rows.
open a shell prompt, navigate to this directory using your shell and execute this script. This regenerates all the JAXB objects..
6. Finally do a Build/Clean All followed by a Build/Make and deploy as normal
Any questions do ask! and yes as I mentioned earlier I plan to create a script to automate all of this.