Thursday, August 15, 2013

Weblogic Tips and Best Practices


- Ensure to take the backup of Config.xml file before making any modifications in weblogic conosle
       MIDDLEWARE/domain/bin/config - Here is the path where you can find config.xml
-  To Start & Stop Weblogic server
        MIDDLEWARE/domain/bin
        ./startWebLogic.sh & - Starts the weblogic server
        ./stopWebLogic.sh   - Stops the weblogic server.

Wednesday, August 14, 2013

How to Start/Stop Weblogic Server

This post briefly outlines about starting/stopping weblogic server in sevral ways.

Start Weblogic Server in Windows

By default, this directory is MW_HOME\user_projects\domains\DOMAIN_NAME, where DOMAIN_NAME is the root directory of the domain. (The name of this directory is the name of the domain.)

- bin/startWebLogic.cmd (Windows)
- bin\startWebLogic.sh (UNIX and Windows. On Windows, this script supports the MKS and Cygnus BASH UNIX shell emulators.)

Starting Weblogic Server from the Windows Startup Menu

- When you create an Administration Server on a Windows computer, the Configuration Wizard creates a shortcut on the Start Menu for starting the server (User Projects > DOMAIN_NAME > Start Admin Server for WebLogic Domain).

How to start Managed server from weblogic console 

- Login to the Weblogic Admin Console
- Environment->Servers
- Click on the 'server' which you want to start/stop



- Choose 'Configuration' and 'Start/Stop' tabs as shown below
- Select the server and click on 'Start/Stop' button.




- If you encounter any warning message saying 'Node Manager is not running associated' then start the 'Node Manager' as explained below

-MW_HOME\wlsserver_10.3\server\bin
startNodeManager.cmd - If it is on Windows
startNodeManager.sh - If it is on UNIX

Starting Weblogic Server using Node Manager

- "Node Manager is a utility for remote control of WebLogic Server instances. Using Node Manager you can control and monitor Managed Servers and also, start, stop, and restart Administration Servers."
- Start Node Manager
c:\>java weblogic.WLST 
wls:/offline> startNodeManager()
- Start WLST
java weblogic.WLST
- Connect WLST to a Node Manager by entering the nmConnect command.
wls:/offline>nmConnect('username','password','nmHost','nmPort', 'domainName','domainDir','nmType')
Example : nmConnect('weblogic', 'welcome1', 'localhost', '5556','fortuneminds','c:/bea/user_projects/domains/fortuneminds','ssl')
- Start Server
wls:/nm/mydomain>nmServerStatus('serverName') 
- Stop Server
wls:/nm/mydomain>nmKill('serverName') 
Ref : http://docs.oracle.com/cd/E12839_01/web.1111/e13715/manage_servers.htm#WLSTG166


Start the admin server:
              <domain_home>/bin/startWebLogic.sh
Stop the admin server:
             <domain_home>/bin/stopWebLogic.sh
Start the node manager:
            <weblogic_home>/wlserver_10.3/server/bin/startNodeManager.sh
Start a managed server:
           <domain_home>/bin/startManagedWebLogic.sh <managed_server_name> http://<admin_server_host>:<admin_port>
Stop a managed server:
          <domain_home>/bin/stopManagedWebLogic.sh <managed_server_name> http://<admin_server_host>:<admin_port>

Sunday, July 21, 2013

How to change the SOA instance state from ? to a valid state




Sometimes I noticed that the SOA suite 11g instance is displayed as Question Mark ("?") which is quite annoying, here is a way to change that setting in the SOA em and capture the proper state of the instance.


·        Right Click on soa-infra domain and select SOA administration > Common properties.
·        Under SOA Infrastructure Common Properties, select Capture Composite Instance State.

How to change the Audit Level for composites in SOA11g ?



It is really useful to turn the audit level in development environment for Testing. SOA11g has 3 levels of audits: Production, Development and Off.

Rightclick on soa-infra domain> SOA Administration> Common properties> and change the audit level to ‘Development’ 


How to display the System Timestamp in XSLT ?



Use the following function to display System Time in XSL with desired format.

<xsl:value-of select="xp20:format-dateTime(xp20:current-dateTime(),'[D01]/[M01]/[Y0001]')"/> - gives the System Date


<xsl:value-of select="xp20:format-dateTime(xp20:current-dateTime(),'  [H01]:[m01]')"/> - gives the System Time

The above XSL functions will display Date Time in the foll. format: 04/10/2009 11:16

How to find the XSLT version that you are using ?



In order to know the XSLT function we are currently working, use the following function:

system-property('xsl:version')

Ex: create a variable and print the XSLT version as follows:

 <xsl:variable name="XSLTVersion">
    <xsl:value-of select="system-property('xsl:version')"/>

  </xsl:variable>

Console urls for most commonly used Oracle Fusion products




Weblogic server console : http://localhost:7001/console

oracle service bus console : http://localhost:7021/sbconsole

Enterprise manager : http://localhost:7001/em

direct url for soa-infra for testing : http://localhost:8001/soa-infra

soa composer for Editing Business rules etc : http://localhost:8001/soa/composer

worklist app : http://localhost:8001/integration/worklistapp

bam console http://localhost:9001/OracleBAM

b2b console : http://localhost:8001/b2b

b2b serices test console : http://localhost:8001/b2b/services

User Messaging Service (UMS) configuration console : 
http://localhost:8001/sdpmessaging/userprefs-ui

Webservice to test UMS : http://localhost:7001/sdpmessaging/parlayx
/SendMessageService

OAM console : http://localhost:7001/oamconsole

Policy manager : http://localhost:8001/wsm-pm

EDN log console: http://localhost:8001/soa-infra/events/edn-db-log

weblogic spy servelet : http://localhost:8001/dms/Spy


How to put and get files using FTP commands ?



Here are some examples to get/put files on a remote machine from local machine via FTP (File Transfer protocol)

Steps to get the files from remote to local machine
- Open commandprompt from AllPrograms in the computer
- Change directory to which you want to put the files on local machine, using cd command (say cd C:\)
- Now connect to remote machine using ftp command (ftp "hostname"), enter username and password.
- Navigate to the folder from which you want to get the files from remote machine using cd command   Ex: cd /Users
- Say mget* and say y when prompted - This will get all the files to local machine (C:\).

Steps to put the files from local to remote machine
- Open commandprompt from AllPrograms in the computer
- Change directory to which you want to put the files from local machine, using cd command (say cd C:\)
- Now connect to remote machine using ftp command (ftp "hostname"), enter username and password.
- Navigate to the folder to which you want to put the files on remote machine using cd command   Ex: cd /Users
- Say mput* and say y when prompted - This will get all the files to local machine(C:\).

- Say mput m* and this will put all the files starting with 'm'.

How to check the source code of a BPEL component in SOA11g EM ?



Here are the steps to get the BPEL component source code from SOA11g em.

- Login to SOA11g em
- Select the corresponding composite and scroll down to components section.
- Select the required BPEL component.
- Click on the blue circle as follows beside the BPEL process and select 'Source' from Definition section.
TestFileConsumer

How to use String tokenize function in XSLT


Here is an example to use String function: tokenize()
Say the csv has element Role seperated by " ; " and we need to translate using tokenize function:

Roles: Supplier;Vendor;Investor

<Roles>
             <Role>Supplier</Role>
             <Role>Vendor</Role>
             <Role>Investor</Role>
</Roles>

XSL Code:

  <Roles>
                <xsl:call-template name="tokenize">
                  <xsl:with-param name="string"
                                  select="/ns0:Role"/>
                </xsl:call-template>
              </Roles>

  <xsl:template name="tokenize">
    <xsl:param name="separator" select="';'"/>
    <xsl:param name="string"/>
    <xsl:choose>
      <xsl:when test="contains($string,$separator)">
        <Role>
          <xsl:value-of select="substring-before($string,$separator)"/>
        </Role>
        <xsl:call-template name="tokenize">
          <xsl:with-param name="string"
                          select="substring-after($string,$separator)"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <Role>
          <xsl:value-of select="$string"/>
        </Role>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:template>

How to use if-else conditional check using XSLT ?



Example for IF – ELSE in XSLT

Following XSLT snippet will display a value for attribute:  PwdChange. If the input xml has ChangePwd, it will disply its value, if it is blank it will display a FALSE value.

   

How to generate a random/unique number in XSLT ?




  <xsl:variable name="RandomNum">
    <xsl:value-of select="orcl:generate-guid()"/>
   </xsl:variable>



Saturday, June 1, 2013

How to implement String Tokenizer using XSLT2.0

How to implement String Tokenizer using XSLT2.0

http://www.xml.com/lpt/a/1205

How to define a variable and assign a value using XSLT

How to define a variable and assign a value using XSLT

Define an element

<xsl:variable name="sampleString">XML,XSLT,XPath,SVG,XPointer</xsl:variable>

<xsl:variable name="empName" select ="emp:EmployeeName"/>

Access the element

<name>
   <xsl:value-of select="$empName"/>
</name>

How to use apply-template and call-template in XSLT

How to use <xsl:call-template> and <xsl:apply-template>
How to implement String tokenizer functionality using XSLT

 I will demo an example how to use call-template recursively in XSLT, that is to tokenizea given string based on specified delimiter.

<xsl:call-template> - Using this, we can invoke a template by name of the template

This is how we can define a template with the name as 'tokenize' and which accepts two parameters 

<xsl:template name="tokenize">
    <xsl:param name="separator" select="';'"/>
    <xsl:param name="string"/>
    <xsl:choose>
      <xsl:when test="contains($string,$separator)">
        <ns0:Role>
          <xsl:value-of select="substring-before($string,$separator)"/>
        </ns0:Role>
        <xsl:call-template name="tokenize">
          <xsl:with-param name="string"
                          select="substring-after($string,$separator)"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <ns0:Role>
          <xsl:value-of select="$string"/>
        </ns0:Role>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

- This is how we invoke the template by passing the parameters
                <xsl:call-template name="tokenize">
                  <xsl:with-param name="string"
                                  select="oim:StringWithDelimiter"/>
                </xsl:call-template>

<xsl:apply-template> - Using this we can invoke template by matching a specific element.

This is how we can define a template to invoke using <apply-template>

<xsl:template match="emp:Employee">
   <emp:Name>
      <xsl:value-of select="emp:FirstName"/>
    </emp:Name>
  </xsl:tempate>

How to invoke a template using <apply-template>

<xsl:apply-templates select="/emp:Employee"/>

Saturday, April 13, 2013

How to invoke a web service from PL/SQL

Usecase: Invoke a webservice from PL/SQL Procedure,

Below is the sample code to invoke BPEL SOA process from PL/SQL stored procedure. Have this stored procedure defined in database.



Create or replace procedure TestBpelInvoke is
    soap_request  varchar2(3000);
    soap_respond  varchar2(3000);
    http_req   utl_http.req;
    http_resp   utl_http.resp;
    resp   xmltype;
    l_xsl_nonamespace  varchar2(1000) := null;
    i    number;
    l_error_loc         number;
    call_error          exception;
    endpoint_url varchar2(1000);
    response_value varchar2(100);
BEGIN
soap_request := '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <ns1:process xmlns:ns1="http://xmlns.oracle.com/BPELInvokeExample/BpelInvokeExample/BPELInvoke">
            <ns1:input1>2</ns1:input1>
            <ns1:input2>3</ns1:input2>
        </ns1:process>
    </soap:Body>
</soap:Envelope>';
endpoint_url := 'http://192.168.1.142:8001/soa-infra/services/default/BpelInvokeExample/bpelinvoke_client_ep';
  http_req:= utl_http.begin_request(endpoint_url,'POST','HTTP/1.0');
  utl_http.set_header(http_req, 'Content-Type', 'text/xml') ;
  utl_http.set_header(http_req, 'Content-Length', length(soap_request)) ;
  utl_http.set_header(http_req, 'SOAPAction', 'process');
  utl_http.write_text(http_req, soap_request) ;
 
 
  http_resp:= utl_http.get_response(http_req) ;
 

  utl_http.read_text(http_resp, soap_respond) ;
  utl_http.end_response(http_resp) ;
 resp := XMLType.createXML(soap_respond);
   l_xsl_nonamespace := '<?xml version="1.0" encoding="UTF-8" ?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="comment()|processing-instruction()|/">  
      <xsl:copy>    
          <xsl:apply-templates/>  
      </xsl:copy>
      </xsl:template>
      <xsl:template match="*">  
      <xsl:element name="{local-name()}">    
          <xsl:apply-templates select="@*|node()"/>  
      </xsl:element>  
      </xsl:template>
      <xsl:template match="@*">  
          <xsl:choose>    
             <xsl:when test="name() != ''xmlns''">      
               <xsl:attribute name="{local-name()}">        
                 <xsl:value-of select="."/>      
               </xsl:attribute>    
             </xsl:when>  
          </xsl:choose>
      </xsl:template>
  </xsl:stylesheet>';
 
  SELECT XMLTransform(resp, xmlType(l_xsl_nonamespace)) into resp from dual;
 
  resp := resp.extract( '/'||'BPELInvoke'||'ProcessResponse/result/child::node()');
  if (resp is null) then
     response_value := '';
  else
     response_value := replace(replace(replace(resp.getStringVal(), '<', '<'), '>', '>'), '"', '"');
dbms_output.put_line('Response Value:'||response_value);
end if;
end;