How to create web service using Database adapter in OSB Console? - database

I have a requirement to use OSB with DB Adapter as for given task, I believe BPEL Process will not be better performer than OSB. I have gone through some sites but all of them are demonstrating OEPE not OSB Console. Any response will be appreciated.

I have similar requirement in my project and I was wondering here and there. Here is final solution of the problem. I documented for you guys.
Steps in JDeveloper
1. Create DB Connection in JDeveloper.
2. Create a Generic Project.
3. Create Project as SOA project and use Empty Composite.
Steps to create DB Adaptor
Go to Composite Palette and choose AD Adaptor.
Drag and drop the DB Adaptor in the External Reference section (right side of Composite view).
It will open a wizard for selecting the connection and Other DB related process.
Give name to service that you want to create
Choose the DB Connection you have created already.
Move one with selecting your desired choice of Stored Procedure or Table (insert/Select) functionality that you want your web service to perform.
If you choose Table insert/Select then you can also choose the relation between tables as optional step.
Try to keep all steps default if you do not want any special features.
Once you finish all steps in wizard, then it will generate whole lot of files under your Project.
Look for 4 main files .jca, xsd/.xsd, *.mapping.xml, *.wsdl
If you see all these files generated well in your project then you are all set and we can move ahead. If not then look for the issue.
Steps in WLS Console
Create Data Source
1.Go to Left panel and choose Data Source.
2. Select New -- Generic Data Source
3. Give Name as you wish but for JNDI Name you have to use the connection name from the *.JCA file that you already have. Open the jca file and search for the ‘UIConnectionName’. This value will be used as JNDI name in data source creation.
4. Choose Driver as oracle.jdbc.xa.client.OracleXADataSource
5. Use the host and Port and other details that you had selected during DB Connection (in JDeveloper). This is obvious step.
6. Choose target AdminServer.
7. If you finish everything correctly. You are all set here and you can choose to test the connection and should be Test Success.
Configure the DB Adaptor
Go to Deployment on left hand panel.
In Deployed services. Search for DbAdaptor.
Click on the name DbAdaptor.
Select Configuration tab. And under it choose Outbound Connection Pool.
Here you will see (javax.resource.cci.ConnectionFactory)
Click on new.
Choose javax.resource.cci.ConnectionFactory
Next page will ask for JNDI Name. For this, you have to go to your *.jca file and choose the value which is already there for Connection-factory as Location (like connection-factory location=?). Use the value of Location as JNDI Name.
Transaction will be No Transaction. Choose this for now. This is need basis selection.
Leave other selection as is and then Finish.
Note : Once you finish. Go to Properties Tab again and look for a property name : xADataSourceName. Its value should be the same as UIConnectionName that you have in *.jca file. It should be populated. If not then you can set now as well. You have to double click on the value section and then write the name and press enter. Then Save it.
With above all steps we have set the DbAdaptor to point to same DB where we have our table/store procedure.
What we did above is:
• We Have JCA File and WSDL for our service. Along with DB Setting.
• We have a Data Source for our DB in WLS.
• We have the deployed DbAdaptor in WLS which is pointing to the same JNDI.
Steps in OSB Console
Create a Project.
Create 3 folders under Project. Like Resources, Proxy Service, Business Service.
Activate your project.
In Resources folder. We have to add JCA Mapping. Point it to the *.jca we already have from above steps (We had created it JDeveloper). Just give the path and Save. It may give you Error. Ignore for Now.
In Resources Folder. Add a WSDL and give the path of your *.wsdl. If it give Error. Then ignore for now.
In Resources Folder. Add a XSD and give path for the *.xsd we already have.
In Resources Folder. Add a XML and give path to the file *Mapping.xml.
Revisit resource WSDL again and click on its name. “Edit References”. Choose the XSD you already have and Save.
Revisit resource JCA and click on its name and edit reference and point it to the mapping.xml
By now you will see all errors gone.
Activate your project.
Go to Left hand side and select the Business Service and Create Business Service by selecting the wsdl project. On next page select Binding.
Then select JCA and give the ‘Location’ of IES (remember we have a value in connection-Factory in *.jca as Location. We had used it while creating DbAdaptor). Give that value here.
Move to next, next and next and finish.
Your business service is all set.
Now create a Proxy Service. Select Proxy Service and choose from B usiness Service option and do select the Business service you have create in above step.
Then click done
Activate your project.
That’s it we are all set. In proxy service you can click and see what is the End Point URl and keep it safe for your future reference. This is the url that we hav eto give on Client to call our service.
With this we all Done.
Call from Client.
Select SOAPUi for this purpose.
Create new project and give the end Point URL.
It will show all the services in it.
Select one service. Create Request.
Put the values in Request XML and Use the endpoint URL by appending your Localhost:port.
Click go and you will see the response back.
So, Finally : We are done with testing a OSB project with DB adaptor.
This looks long, but once you do it, its very easy for next services.
Thanks, Hope that will help.

The OSB Console does not support creation of the JCA DB Adapters, and neither does OEPE.
You need to create the DB Adapter in JDeveloper and then import it via OEPE/OSB Console. OEPE is easier ;-).
For a guide, see:
http://guidoschmutz.wordpress.com/2010/08/08/oracle-service-bus-11g-and-db-adapter-a-different-more-integrated-approach/
or
https://blogs.oracle.com/middleware/entry/using_jca_adapter_with_osb_11113

Related

Where to find the OSB Business service configuration details in the underlying database?

In OSB Layer when the endpoint uri is changed, I need to alert the core group that the endpoint has changed and to review it. I tried SLA Alert rules but it does not have options for it. My question is, the endpoint uri should be saved somewhere in the underlying database. If so what is the schema and the table name to query it.
URI or in fact any other part of OSB artifact is not stored in relational database but rather kept in memory in it's original XML structure. It can be only accessed thru dedicated session management API. Interfaces you will need to use are part o com.bea.wli.sb.management.configuration and com.bea.wli.sb.management.query packages. Unfortunately it is not as straightforward as it sounds, in short, to extract URI information you will need to:
Create session instance(SessionManagementMBean)
Obtain ALSBConfigurationMBean instance that operates on SessionManagementMBean
Create Query object instance(BusinessServiceQuery) an run it on ALSBConfigurationMBean to get ref object to osb artifact of your interest
Invoke getServiceDefinition on your ref object to get XML service
definition
Extract URI from XML service definition with XPath
Downside of this approach is that you are basically pooling configuration each time you want to check if anything has changed.
More information including JAVA/WLST examples can be found in Oracle Fusion Middleware Java API Reference for Oracle Service Bus
There is also a good blog post describing OSB customization with WLST ALSB/OSB customization using WLST
The information about services and all its properties can be obtained via Java API. The API documentation contains sample code, so you can get it up and running quite quickly, see the Querying resources paragraph when following the given link.
We use the API to read the service (both proxy and business) configuration and for simple management.
As long as you only read the properties you do not need to handle management sessions. Once you change the values, you need to start a session and activate it once you are done -- a very similar approach to Service bus console.

Access Sitecore DB from API in Console application

I would like to accesss the sitecore DB and items from console application like
Sitecore.Data.Database db = Sitecore.Context.Database
or
Sitecore.Data.Database db = Sitecore.Data.Database.GetDatabase("master")
how do I configure and setup my console application to access the DB as above?
Thanks Everyone for the suggestion, I am really interested in config changes, I used webservice, but it has very limited methods. For example, if I would like create an Item with the template and insert the item with prepopulated value, there is no such option. The reason I am looking for the console apporach is I would like to import the contents from XML or excel sheet and push those to the sitecore tree, eventually use the scheduled task to run the console app periodically. I do not want to copy the entire web.config and app_config. If anyone has already done this, could you please post your steps and necessary config changes?
You have two options I think:
1) Import the Sitecore bits of a website's web.config into your console application's app.config, so that the Sitecore API "just works"
I'm sure I read a blog post about this, but I can't find the reference right now. (I will have another look) But I think the simple but long winded approach is to copy all of the <sitecore/> element and all the separate files it references. I'm fairly sure you can whittle this down to a subset of the config required for data access with a bit of thinking.
2) Don't use the Sitecore API directly, connect to a web service that exposes access to it remotely.
There are a few of these that already exist. Sitecore itself exposes one, Sitecore Rocks has one, and Hedgehog TDS has one too. And you can always write your own (since any web service running inside the Sitecore ASP.Net app can make database calls and report values back and forth - just remember to consider security if this web service might end up exposed externally for any reason)
John West links to some relevant stuff here:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/09/Getting-Data-Out-of-the-Sitecore-ASPNET-CMS.aspx
-- Edited to add --
I've not found the blog post I remember. But I came across this SO thread:
Accessing Sitecore API from a CLI tool
which refers to this blog post:
http://www.experimentsincode.com/?p=232
which I think gives the info you'll need for option 1.
(And it reminds me that, of course, when you copy the config stuff you have to copy the Sitecore binaries into your app's folder as well)
I would just like to expand on #JermDavis' post and note that Sitecore isn't a big fan of being accessed when not in a web application. However, if you still want to do this, you will need to make sure that you have all of the necessary configuration settings from the web.config and App_Config of your site in your console application's app.config file.
Moreover, you will never be able to call Sitecore.Context in a console application, as the Sitecore Context sits on top of the HttpContext which means that it must be an application and have a valid request for you to use it. What you are looking for is something more along the lines of Sitecore.Configuration.Factory.GetDatabase("master").
Good luck and happy coding :)
This sounds like a job for the Sitecore Item Web API. I use the Sitecore Item Web API whenever I need to access Sitecore data from the master database outside the context of the Content Management server or outside of the context of the Sitecore application. The Web API definitely does not allow you to do everything that the standard Sitecore API does but it can act as a good base and I now extend upon the Web API instead of writing my own custom web services whenever possible.
Thanks to JemDavis's advise.
After I copied the configuration and made changes to config section to get rid of conflicts. I copied almost all of Sitrecore, analytics and lucene dlls, it worked great.
Only thing you have to remember is, copy the app_config folder to the same location where your dlls are.
Thanks again JemDavis....

Liferay document checkin issue

I'm still new to Liferay and using Liferay 6.2
what i'm doing:
I am trying to add a document manually into my database using insert statement.
I inserted into dlfileentry, dlfileversion and AssertEntry.
Also, i created a folder with the valid name and file.
The issue:
upon entering the Documents and Media portlet, i can see the document name there but when i click on checkout, it will prompt a error saying that Documents and Media is temporarily unavailable. however i am still able to download the valid document.
Am i doing something wrong? Personally, i feel that i am missing one more table for the database but i'm not sure .
Thanks!
Yes, you're doing something wrong: You should never write to Liferay's database with SQL, as there might be more data required than what's directly visible to you. Obviously, you're running into exactly such an issue.
Liferay has an API which you can use locally, from within the same application server, or remotely as JSON or SOAP service. You should exclusively use this for write access to the database.
Alternatively, you might consider WebDAV access to your document repository as the way to add more documents to the document library.

Remote Site Setting in Salesforce

Can we add a list of domain like this :
www.google.*
into Remote Site Setting.
Google has a lot of domain :
google.com.ar
google.com.au
google.ca
....
I don't believe you can. See here for an old question that was left unanswered.
Remote Site Settings are only for HTTP calls you make from Salesforce out to another server, so if you know your contained list for outbound calls you shouldn't have to worry about new ones dynamically being needed. If you want a faster way to update this, take a look at the Metadata API, which should let you bulk change the values through underlying XML (with the caveat that you need at least one Remote Site defined in the org first).

Sitecore Analytics error

I can't make Sitecore Analytics working. I have Sitecore 6.6.0 (rev. 121015) and installed Sitecore DMS.
1) when i go to Sitecore->Marketing Center i get error XML Parsing Error: no element found
2) when i go to Sitecore->Content Editor, choose element and press Analyze->Reports I get error You do not have permission to see any item reports
3) In Content Editor when press Analyze->Goals get Cannot use Analytics with a database that has no definition items error
4) in logs I see following:
"Exception: System.InvalidOperationException
Message: Cannot use Analytics with a database that has no settings"
5) If I change url that i get trying to open Marketing Center (changing Marketing%20Center.aspx to Marketing%20Center/default.aspx) I get Cannot use Analytics with a database that has no definition items error
6) I have in my Sitecore.Analytics.config this tag:
<setting name="Analytics.DefaultDefinitionDatabase" value="web" />
I tried to give access to analytics database from SQL Management Studio, but didn't help.
What could be the reason of this error, and how to solve it?
Your errors seem to suggest that the database is missing data. Did you use the database provided on this page, http://sdn.sitecore.net/Products/Sitecore%20V5/Sitecore%20CMS%206/Update/6_6_0_rev_121015.aspx ?
Go to the link above, scroll down to Download DMS 6.6.0 rev. 121015 for Sitecore CMS 6.6.0 rev.121015 and click the Download DMS 6.6.0 rev.121015 under SQL Server. Attach this database to your server and try again.
I haven't seen these errors, but it sounds to me like Sitecore is not able to access the Analytics database at all. You do have a connection string in ConnectionStrings.config named "analytics"? Try using the sa account just to make sure it's not a permissions issue. Don't forget to change it back from sa either way.
(caveat: I haven't used DMS yet, just OMS... it's possible I am way behind the times)
Publish your site (to web). You might be trying to analyze data that isn't live.
I just erased my previous answer as that was a consequence of what was wrong, but not the actual cause...
In the Analytics code, the Marketing Center node is requested from the current database. If it cannot find that item (which IS in the master database), you get the error.
But the code will NOT find the marketing center item if the security settings prevent the anonymous user read access...
That is where the error occured for me, when I was an anonymous user... And effectively, when looking at the security settings for the Marketing Center Item I found that inheritance had been blocked, hence preventing read access for the anonymous user...
Another reason this error sometimes occurs is when you have a production environment where there is no access to the master database.
Since the Analytics code uses the "master" database as the default definition database unless otherwise specified in the config settings, you could add the following to analytics.config:
<setting name="Analytics.DefaultDefinitionDatabase" value="web" />
That way, it will fallback to the web database in case of a production environment without master database.
Hope this helps...
Erwin
The issue is due to Sitecore not being able to read the definition items in the master/web database (depending on the Analytics.DefaultDefinitionDatabase setting).
The items it is looking for are:
/sitecore/system/Marketing Control Panel
/sitecore/system/Settings/Analytics
When the request is running, the user is default\Anonymous. Using Access Viewer, make sure there are no security settings disabling read access to these items. This includes parent items that would have a trickle-down effect.

Resources