?

Log in

Profiler

Feb. 13th, 2007 | 03:43 pm

Jprobe is an excellent profiler for J2EE Applications which supports weblogic, oc4j ... It also represents the flow of control in a diagram and provides the ability to prune subtrees.

Link | Leave a comment {4} | Share

Code coverage

Feb. 13th, 2007 | 03:25 pm

A nice introduction here
1. Instrument the WS.jar using EMMA – this writes to coverage.em //Metadata
java -cp emma.jar emma instr -m overwrite -cp ..\..\WS.jar
The WS.jar gets overwritten
2. replace the WS.jar with the instrumented one
3. Add emma.jar to the web-inf\lib of the application
4. When the application terminates the coverage.ec is written to %ORACLE_HOME%\j2ee\home for OC4J
5. Use the coverage.em and coverage.ec to generate the report
java -cp emma.jar emma report -r html -in coverage.em,coverage.ec
6. View the htm file in coverage\index.htm

Link | Leave a comment | Share

obj.getobjA().getobjB()?

May. 26th, 2006 | 02:20 pm

It is wrong to use the above statement because there is no way to check if the objA was null or not!
Tags: , ,

Link | Leave a comment | Share

Sample WS client using AXIS APIs

May. 22nd, 2006 | 08:22 pm

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

public class AxisClient {
public static void main(String [] args) throws Exception {
String endpoint = "http://machinexyz:8888/WS-BasicAuthWS/BasicAuthWS";
Service service = new Service();
Call call = (Call) service.createCall();
call.setProperty(Call.USERNAME_PROPERTY, "developer");
call.setProperty(Call.PASSWORD_PROPERTY, "welcome");
call.setProperty(Call.OPERATION_STYLE_PROPERTY, "rpc");
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("sayHello");
call.setReturnType(XMLType.XSD_STRING);
String ret = (String)call.invoke(new Object[0]);
System.out.println("Got result : " + ret);
}
}

If the Webservice is not protected by Basic Authentication then there is no need to set the Username and Password property.
Tags: , , ,

Link | Leave a comment | Share

Invoking a stateful webservice

May. 22nd, 2006 | 06:54 pm

Using Oracle's API
Set the m_httpConnection.setMaintainSession(true) before calling the webservice. Setting this property to true will result in sending cookie values thereby maintaining state.

m_httpConnection is of type OracleSOAPHTTPConnection

Using Axis API

call.setmaintainsession(true) where call is object of type org.apache.axis.client.Call
Tags: , ,

Link | Leave a comment | Share

Access a URL protected by Basic Authentication via WS client

May. 17th, 2006 | 04:03 pm

In the Webservice client code define properties and set them on the OracleSOAPHTTPConnection object. Set this HttpConnection object while creating the call.

Properties props = new Properties();
props.put(OracleSOAPHTTPConnection.AUTH_TYPE, "basic");
props.put(OracleSOAPHTTPConnection.USERNAME, "developer");
props.put(OracleSOAPHTTPConnection.PASSWORD, "welcome");
props.put(OracleSOAPHTTPConnection.REALM, "WebServices");
m_httpConnection = new OracleSOAPHTTPConnection();
m_httpConnection.setProperties(props);

Call.setSoapTransport(m_httpConnection)

Link | Leave a comment {5} | Share

Process SOAP headers in the Webservice

May. 17th, 2006 | 03:50 pm

On the Webservice side Implement HeaderCallback in the class deployed as webservice. The function public void processHeaders(Header header) provides access to the headers in the SOAP message.
On the client side the header can be set using call.setHeader(header);

Link | Leave a comment | Share

WS-Security

May. 10th, 2006 | 12:26 pm

WS-Security is Protocol Independent, support for encryption + signing, Authentication using SAML, Username/Password, X.509. This is a Message oriented security.

Protocol based security is using HTTPS, JAAS.

Providers of Protocol based security
--------------------------------------------

1. Apache
Provides support for basic/digest Authentication
Supports HTTPS
Supports X.509

2. Webcontainer (JAAS)
In OC4J
Provides Basic Authentication using the browser, SSL , SSO
In SSO, SSO server performs the authentication.
The authentication is done against either the LDAP based system or the file based system! In oc4j the LDAP service is provided by OID and the file is jazn-data.xml

Link | Leave a comment | Share

Basic Authentication in Oracle IAS

May. 9th, 2006 | 10:21 am

In $ORACLE_HOME/Apache/Apache/conf/httpd.conf add the following statements

[Error: Irreparable invalid markup ('<directory "c:\oracle\apache\apache\htdocs\doc\images">') in entry. Owner must fix manually. Raw contents below.]

In $ORACLE_HOME/Apache/Apache/conf/httpd.conf add the following statements

<Directory "C:\oracle\Apache\Apache\htdocs\doc\images">
AuthType Basic
AuthName "Restricted Files"
AuthUserFile "C:\oracle\Apache\Apache\bin\passwords\basicpasswd"
Require user testuser
</Directory>

The line which includes mod_osso.conf needs to be commented!

Link | Leave a comment | Share

Table Generator for laying out images

May. 7th, 2006 | 01:47 pm
mood: accomplished

# Tablegen.pl
#!/bin/perl

############################# Customisable variables ###################
#
# Data file format
# ----------------
# img_link1 href_link1
# img_link2 href_link2
# ...
#
# File names
$inputdatafile = "data";
$outputdatafile = "html";

#image info
$thumbnailwidth=100;
$thumbnailheight=75;
$reqborderfortd = 1;

#Algo customisations
$increaseswapfactor =4;
$minrow =2;
$mincol = 4;
$additionalrows =2;
$additionalcolumns = 2;
$noofimgsThreshold1 = 4;
$noofimgsThreshold2 = 8;
##################################################################

# Table Headers
$begintbl =""; $endtbl ="
";
$beginrow = "<tr>";
$endrow = "</tr>";
$begindata = "
[Error: Irreparable invalid markup ('<td [...] "."width>') in entry. Owner must fix manually. Raw contents below.]

# Tablegen.pl
#!/bin/perl

############################# Customisable variables ###################
#
# Data file format
# ----------------
# img_link1 href_link1
# img_link2 href_link2
# ...
#
# File names
$inputdatafile = "data";
$outputdatafile = "html";

#image info
$thumbnailwidth=100;
$thumbnailheight=75;
$reqborderfortd = 1;

#Algo customisations
$increaseswapfactor =4;
$minrow =2;
$mincol = 4;
$additionalrows =2;
$additionalcolumns = 2;
$noofimgsThreshold1 = 4;
$noofimgsThreshold2 = 8;
##################################################################

# Table Headers
$begintbl ="<table border=\"1\" cellspacing=\"1\">";
$endtbl ="</table>";
$beginrow = "<tr>";
$endrow = "</tr>";
$begindata = "<td "."width=$thumbnailwidth height=$thumbnailheight".">";
$enddata ="</td>";

# variables
$i=0;



# Open the data file
print "Reading from Input data file: $inputdatafile"."\n";
open (ipdatafile, "< $inputdatafile") || die ("Could not open file. <br> $!");
while (<ipdatafile>){
chomp($_);
if($_ ne "" && $_ ne "#")
{
($imgarr[$i], $hrefarr[$i]) = split(/ /);
$i++;
}
}
sort(@imgarr); # randomises a bit! unless the input is already sorted
sort(@hrefarr);
close (ipdatafile);

print " Totalimgs = $i"."\n";
# No work to do :(
if ($i == 0)
{
print "No data!";
exit(0);
}

# Generate the Table Html code
print "Writing to the output file : $outputdatafile"."\n";
open (opdatafile, "> $outputdatafile") || die ("Could not open file. <br> $!");

if($i <= $noofimgsThreshold1)
{
$noOfRows = 1;
$noOfColumns = 1;
}
else
{
if($i <=$noofimgsThreshold2 )
{
$noOfRows = int(rand($i));
if($noOfRows == 0)
{
$noOfRows =$minrow;
}
$noOfColumns = int($i/$noOfRows) + $additionalcolumns;
}
else
{
$noOfColumns =int(rand($noofimgsThreshold2));
if($noOfColumns == 0)
{
$noOfColumns=$mincol;
}
$noOfRows = int($i/$noOfColumns) + $additionalrows;
}
}

print "Number of Rows in Table : $noOfRows"."\n";
print "Number of Columns in Table : $noOfColumns"."\n";

print opdatafile $begintbl."\n";

if($noOfRows == 1 && $noOfColumns == 1)
{
print opdatafile $beginrow."\n";
for($j=0; $j<$i;$j++)
{
print opdatafile $begindata;
print opdatafile "<a href=\""."$hrefarr[$j]"."\">";
print opdatafile "<img src=\""."$imgarr[$j]"."\"/>";
print opdatafile "</a>";
print opdatafile $enddata."\n";
}
print opdatafile $endrow."\n";
print opdatafile $endtbl;
}
else
{
$totalboxes = $noOfRows * $noOfColumns;
$extradata = $totalboxes - $i;

for( $j = 0; $j < $totalboxes; $j++ )
{
$randomarr[$j]=$j;
}

for( $j = 0; $j < $increaseswapfactor*$totalboxes; $j++ )
{
$idx1 = int(rand($totalboxes));
$idx2 = int(rand($totalboxes));
if($idx1 !=$idx2)
{
$temp = $randomarr[$idx1];
$randomarr[$idx1]=$randomarr[$idx2];
$randomarr[$idx2]=$temp;
}
}

for( $j = 0; $j < $extradata; $j++ )
{
$valtoinsert = $randomarr[$j];
$hash{$valtoinsert}=$valtoinsert;
}

print "Selected Boxes :";
for($j = $extradata; $j<$totalboxes; $j++)
{
print $randomarr[$j]." ";
}

print opdatafile $beginrow."\n";
$k=0;
for( $j=0; $j < $totalboxes; $j++ )
{
print opdatafile $begindata;

if(!$hash{$j} && $k<$i)
{
print opdatafile "<a href=\""."$hrefarr[$k]"."\">";
print opdatafile "<img src=\""."$imgarr[$k]"."\"/>";
print opdatafile "</a>";
$k++;
}
else
{
if($reqborderfortd == 1)
{
print opdatafile "&nbsp;";
}
}

print opdatafile $enddata."\n";

if( ($j+1) % $noOfColumns == 0 )
{
print opdatafile $endrow."\n";
if(!($j+1 == $totalboxes))
{
print opdatafile $beginrow."\n";
}
}

}
print opdatafile $endtbl;
}

close(opdatafile);
exit(0);

################# Sample data file contents############################
http://static.flickr.com/49/129330943_c45adf2a7f_t.jpg http://static.flickr.com/49/129330943_c45adf2a7f_o.jpg
http://static.flickr.com/54/129330366_d80db7c4bb_t.jpg http://static.flickr.com/54/129330366_d80db7c4bb_o.jpg
http://static.flickr.com/50/129330149_945b80f6e1_t.jpg http://static.flickr.com/50/129330149_945b80f6e1_o.jpg
http://static.flickr.com/49/129329956_a711deec4d_t.jpg http://static.flickr.com/49/129329956_a711deec4d_o.jpg
###################################################

Link | Leave a comment | Share