Thursday, 16 February 2017

Retrieve or set a HTTP header from Oracle BPEL

First step is to add a property to the binding.ws element of the service in the composite.xml.
Add a property with name oracle.webservices.http.headers and as value the HTTP headers 
you want to use in BPEL
<property name="oracle.webservices.http.headers">username,message</property>


Next step is to define some BPEL variables for those HTTP Headers


In the receive activity of the BPEL process we can use fromProperty to copy the HTTP header property 
value to the BPEL variable. 

Do this in the BPEL source mode. 


Now you can use these variables in BPEL, I will use these vars in the return message.

Let's invoke the service from soapUI, we need to set the HTTP header properties with their values.













When we want to invoke a reference service and we also want to set some HTTP header properties.

We need also need to set the http.headers property on the binding.ws element on the 
reference in the composite.xml

<property name="oracle.webservices.http.headers">username,message,message2</property>


On the invoke of the reference service we need to use the toProperty and set the BPEL vars to these 
HTTP header properties.
I changed the toProperties to inputProperty and the Header information was being 
passed successfully.













When we test it again in soapUI we can see the invoke request of the soapUI mockservice, this contains 
the HTTP headers which we set in the BPEL process.


Friday, 10 February 2017

Data Source Configuration Steps

Creating a Data Source
1.      In the Domain Structure Section, expand Services and then click on Data Sources
Select Data Sources
2.      In the Change Center section on the top left corner of the screen, click Lock & Edit. If you don’t have this option, don’t worry. That just means that in Preferences (which can be found at the top center of the screen), you’ve unchecked the option for “Automatically Acquire Lock and Activate Changes.”
Lock And Edit
3.       In the Summary of JDBC Data Sources section in the center of your screen, click New and then click Generic Data Source
New Generic Data Source
4.       Since we’re going to connect to the CUSTOMER_STAGING database, let’s set the name as “CustomerStaging” and then set the JNDI Name as “jdbc/CustomerStaging”. You can leave the database type as “Oracle”. Click Next
Create a new JDBC Data Source
5.       On the next screen, you can leave the default Oracle Thin XA driver. However, you should always choose the appropriate database driver for your project. The support matrix for the Oracle Database Adapter is located on the following spreadsheet http://www.oracle.com/technetwork/middleware/downloads/fmw-11gr1certmatrix.xls. This spreadsheet came from the following page which contains information about all Fusion Middleware Supported Configurations: http://www.oracle.com/technetwork/middleware/ias/downloads/fusion-certification-100350.html. For our purposes here, accept the default and click Next
Database Driver
6.       The next screen, for our purposes, presents a message informing you that the XA driver you’ve chosen supports global transactions and uses the 'Two-Phase Commit' global transaction protocol. Whenever possible, always choose XA drivers when you’re using them for database adapters within BPEL or BPMN projects. This is because if you execute several database scripts within a single scope and then experience an exception, the process engine will be able to roll back these changes in order to recover cleanly. If you want to learn more, I would highly recommend the following article which does the best job I’ve seen so far of discussing how XA transactions work in a business process: http://www.oracle.com/technetwork/articles/soa/wli-bpel-transactions-088255.html. For this example, you don’t have to do anything on this screen but click Next.
7.       Here you will define the connection properties. Please note that the ones I’ve listed are specific to the Oracle VM VirtualBox instance I’m using for this demo. Click Next when finished
·         Database Name: xe
·         Host Name: soabpm-vm
·         Port: 1521
·         Database User Name: CUSTOMER_STAGING
·         Password: CUSTOMER_STAGING
Define Connection Properties
8.       Here you will define the connection properties. Please note that the ones I’ve listed are specific to the Oracle VM VirtualBox instance I’m using for this demo. Click Next when finished
http://www.avioconsulting.com/sites/default/files/page-images/u67/CreateNewDataSource5.jpg
8.       On the Summary page, be sure to click “Test Configuration” and even more importantly, be sure that you see a success message stating “Connection test succeeded.” If you don’t see this, go back and correct any problems you have in the prior screens. Once you get a success message you can click Next.
Test Configuration
9.       For this example, simply choose “AdminServer” as your target. However, for a real project, this will depend greatly upon how your environment is configured. In a real implementation, you would probably target your SOA or ADF cluster rather than the admin server. Click Finish.
Select Target
10.   In the Change Center section in the upper left of your screen, click Activate Changes and be sure that you see a message saying “All changes have been activated. No restarts are necessary.” It’s important to note that if you ever need to update your data source, you will need to restart your WebLogic server before the changes will take effect. This message at the top of your screen will always inform you if a restart is necessary.
Activate Changes

Creating a Database Connection Pool
1.       In the Domain Structure panel on the left, click on Deployments
Deployments
2.       In the Summary of Deployments panel in the middle of the page, click on the DbAdapter link
DB Adapter
3.       In the Settings for DbAdapter panel in the middle of the page, click on the Configuration tab
Configuration Tab
4.       Click on the Outbound Connection Pools tab
Outbound Connection Pools
5.       In the Change Center section on the top left corner of the screen, click Lock & Edit.
6.       In the Outbound Connection Pool Configuration Table, click New
New Outbound Connection Pool
7.       In the Outbound Connection Groups table, select the radio next to javax.resource.cci.ConnectionFactory and click Next
Choose a Connection Group
8.       Set the JNDI Name to “eis/DB/CustomerStaging”. This is how we’ll identify this Outbound Connection Pool. Click Finish
Set Pool JNDI Name
9.       In the Outbound Connection Pool Configuration Table, expand javax.resource.cci.ConnectionFactory and click on “eis/DB/CustomerStaging”
Select New Connection Pool JNDI
10.   In the Settings for javax.resource.cci.ConnectionFactory panel, click on the Property Value column within the last row, which is labeled “xADataSourceName”. It is important to note that before click away from this cell, you must hit the Enter key for this change to register on the screen. The following link describes specifics around each of these settings: http://docs.oracle.com/html/B25307_02/adptr_db.htm#CHDDCFDJ. If you are connecting to a non-Oracle database, you will need to change the platformClassName, which is also discussed in the link. For our purposes here, once you see the new xADataSourceName in the table, click Save
Set xADataSourceName
11.   Be sure that you see a message at the top of the screen saying “Deployment plan has been successfully updated.”
Deployment Plan Successfully Updated
12.   In the Domain Structure panel on the left, click Deployments
13.   In the Summary of Deployments panel in the center of your screen, click the checkbox next to DbAdapter and then click Update
Update DB Adapter
14.   In the Update Application Assistant panel in the center of your screen, be sure that the following radio button is chosen: “Redeploy this application using the following deployment files”. Note that this screen shows the location of 2 files that are about to be changed. Click Finish
Update Deployment Files
15.   Make sure you see a message at the top of the screen saying, “Selected Deployments were updated.”
Deployments Updated Msg
16.   In the Change Center panel in the upper left corner of your screen, click “Activate Changes”
17.   Again, ensure that the message that the top of the screen reads, “All changes have been activated. No restarts are necessary.”
Changes Activated


Wednesday, 25 January 2017

Webservice invocation failed, Unable to access the following endpoint(s) – Oracle SOA Suite 11g

Webservice invocation failed, Unable to access the following endpoint(s) – Oracle SOA Suite 11g:

Some of the time we used to receive the following exception while invoking the webservice endpoints in Oracle SOA 11g. There could be a multiple reason behind this exception.

This blog explains the different ways to narrow down the issue and to fix the issue.

An exception occured while invoking the webservice operation. Please see logs for more details.
oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Unable to access the following endpoint(s): http://hostname:50000/XISOAPAdapter/MessageServlet?channel=:SalesForce:CC_Out_Soap_SFDC_order

Steps:-   

Ping the host name: 
    • If the host is alive then the connectivity looks fine

    •  If we received Unknown host error then verify whether the host entry is available in the server host  file for the host.


    •   If the host is configured to lookup by DNS server then verify the DNS server configuration.

Telnet to the server with the corresponding port:
    • If the telnet is success then the connectivity looks fine.
    •  If the telnet is failed then check the network connectivity between the server and the webservice host in that particular port

Check the webservice status:
    • If the network connectivity between the two servers are looks fine then check whether the webservice is up and running.
    • Some cases the status of the service in the target system shows as up and running but due to some internal errors with the service the source system may not able to connect to the target service . For e.g. sometime the client will not be able to connect to the Siebel services due to some internal table locking but the status of the service will be shown as up and running in Siebel system. 
Check the webservice authentication configured properly:
    • If the webservice up and running properly then check whether the service is protected with username/password. If the service is protected with username/password then check the username/password configuration in the composite.xml file. 
                    You will be receiving the same exception if the username/password is not configured properly. 

Sometimes we used to get the exception in the em console

oracle.fabric.common.FabricInvocationException: Unable to access the following endpoint(s): https://sap.int.com/XISOAPAdapter/MessageServlet?channel=*:Markets_Siebel_QA:CC_Out_Soap_SalesOrder

But the actual exception in the server log

Caused By: javax.xml.ws.WebServiceException: javax.xml.soap.SOAPException: javax.xml.soap.SOAPException: Message send failed: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


Verify the certificate installed properly in the server and also the certificate not expired.

Friday, 13 January 2017

Adding authentication to your webservice in SOA Suite 11G

When you build a component which has an exposed service, you want to make sure that it is secure. This means we have to apply authentication and authorization to the service in question. Lets see how we can get this done in the SOA Suite 11G (PS2).
First of all we have already created a webservice which we are going to expose in my example an EventDispatcher which sends out events using the EDN.
Now lets say we want to secure this webservice using WS-Security, the username-token variant. The only thing we need to do is to right-click the service and choose: Configure WS Policies
In the next screen you can choose different policies for your webservice but the one we are looking for in under security. Click the green + sign at the Security tab and choose: oracle/wss_username_token_service_policy.
Click OK and check that your policy is selected in the Security section. If so, click OK. This policy will now make sure that if you send a ws-s header with your request, it will be processed. Adding this policy can also be done in the Enterprise Manager by the way. Select you component under SOA and select the Policies tab. Here you can do the same.
Now al we need to do is to make a user of which the credentials will be checked when he/she wants to make use of this service..
Go to your Weblogic administration console and click on Security Realms.
Next click in on ‘myrealm’ and click on the ‘Users and Groups’ tab. Click ‘New User’ and enter the information for the user you want to authenticate. Make sure your password if 8 characters long and contains at least 1 number.

Click OK if you are ready. The next thing is to create a group of which the user is a member. Select the ‘Groups’ tab and click ‘New’. Now insert the info of your group.
If your done, click on OK. You can now use this user to check if we have access to the service. In SoapUI you can create configurations which you can use to call a webservice. Make one for the user you have just created.
Now let’s try to call the service without a security configuration. It should look something like this.
Now select the Test configuration


and make the call again. You should now get a proper response from the server. This is the end of part 1 of this small tutorial…..authentication of a webservice in SOA Suite 11g using ws-security. In the next post, I will show you how you can make sure only users which are a member of the created group, can make use of the service.