Monday, May 18, 2009

A tricky problem for xml validation

There's an interesting article about XML Schema nillable=”true” vs minOccurs=”0″ in Dimithu's blog. minOccurs is an xml attribute that most people understand; but for nillable="true", people might understand its meaning; however, how to use it in a correct way is not well known. By "correct way", I mean "the way that complies with W3C specifications".
Actually, a lot of software vendors are not clear about its usage as well. This leads to interoperability problems. Some BPM/SOA vendors implement different validation rules for a "nillable" tag, which are not in accordance with W3C specifications. 

Imagine an application is built which utilizes web services from different external system, and those web services require web service validation. The problem occurs that some systems send out the message which they consider as valid, while it's rejected by other systems due to different interpretation of "wsdl/soap validity". 

In short, the problem can be described as follows:
When an element is defined in wsdl using  xs:element name="nilint" nillable="true" type="xs:int"

The nilint element in the soap message should look like this if it's an empty node:
nilint xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/
If it's not an empty node, we can remove the contained attribute because by default the value for nil is "false".

Considering the aforementioned scenario, if some development tools that are used to build the SOA application don't provide support for the nil tag, we need to find some way to workaround the issue. The normal way to do it is to create an interceptor class whenever the soap message is being sent out.
This looks like a minor issue, but indeed a lot tools have problems with it; for example, wsdl validation function in SoapUI does not work in a correct way.

Friday, May 08, 2009

Check Oracle tablespace

Here's the script to check oracle table space:

select d.status,   db.name dbname,   d.tablespace_name tsname,   d.extent_management,   d.allocation_type,   to_char(nvl(d.min_extlen / 1024, 0),     '99G999G990D90', 'NLS_NUMERIC_CHARACTERS = '',.'' ')     "ALLOC_SIZE (K)",   d.contents "Type", case when(d.contents = 'TEMPORARY') then   to_char(nvl(a.bytes / 1024 / 1024, 0),   '99G999G990D90', 'NLS_NUMERIC_CHARACTERS = '',.'' ') else   to_char(nvl(t.bytes / 1024 / 1024, 0),   '99G999G990D90', 'NLS_NUMERIC_CHARACTERS = '',.'' ') end as "Size (M)",   to_char(nvl((a.bytes - nvl(f.bytes, 0)) / 1024 / 1024,   0),   '99G999G990D90', 'NLS_NUMERIC_CHARACTERS = '',.'' ')   "Used (M)",   to_char(nvl((a.bytes - nvl(f.bytes, 0)) / a.bytes * 100,   0),   '990D90', 'NLS_NUMERIC_CHARACTERS = '',.'' ')   "Used (%)" from sys.dba_tablespaces d,     (select tablespace_name,      sum(bytes) bytes    from dba_data_files    group by tablespace_name) a,     (select tablespace_name,      sum(bytes) bytes    from dba_temp_files    group by tablespace_name) t,     (select tablespace_name,      sum(bytes) bytes    from dba_free_space    group by tablespace_name) f,   v$database db where d.tablespace_name = a.tablespace_name(+)  and d.tablespace_name = f.tablespace_name(+)  and d.tablespace_name = t.tablespace_name(+) order by 10 desc;

Monday, April 20, 2009

check tcp traffic between servers

Here's the troubleshooting command for tcpdump:

tcpdump -A -s 0 -l 'dst host hostname'

Another example:
tcpdump -nnvvXSs 1024 src 10.94.242.73 and dst port 80 and greater 512


It'll capture 1024 bytes for the request with the size bigger than 512 bytes, and from a specific source server to the http port (80)

drop all tables in an Oracle schema

Here's the script to drop all tables in a schema:

SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET MARKUP HTML OFF
SET ESCAPE \
SPOOL DELETEME.SQL
select 'drop table ', table_name, 'cascade constraints \;' from user_tables;
SPOOL OFF
@DELETEME

Friday, January 16, 2009

PL/SQL Tips - 1

1. Create procedure, function
procedure (...) is begin end;
function (...) return ... is ... begin end;
in, out, in out parameters.
2. Create package
package header (interface): create or replace package pkg as ... end;
package body (implementation): create or replace package body pkg as ... end;
3. Check objects created by user
select object_type, object_name, status from user_objects where object_type in ('FUNCTION','PROCEDURE','PACKAGE','PACKAGE BODY') order by object_type;
It's stored in the table called "user_objects".
4. Check implementations
select text from user_source where name= 'F_GETAREA_NR' order by line;
It's stored in the table called "user_source".

Wednesday, November 26, 2008

Dumping Oracle schema

Here's the link to dump an Oracle schema:
http://www.tek-tips.com/viewthread.cfm?qid=1301609&page=34

Command
(sample format)exp buffer= compress= grants= feedback= consistent= file= log= owner= userid=/@

(example invocation with sample values)exp buffer=15000000 compress=n grants=y feedback=1000 consistent=y file=DHUNT.TEST.dump log=TEST_Exp.log owner=TEST userid=TEST/TEST@dhunt

"buffer=" : give a large value, which speeds the export"compress=" : "Y" means 'allocate as an initial extent an extent size that accommodates the ENTIRE contents of the table'. "N" means 'use the standard "initial" and "next" parameters for the table. (I use "N" to avoid receiving the Oracle "Unable to allocate initial extent..." error.)"grants=" : "Y" means export the grant on this object; "N" means don't bother exporting grants. Use "N" if the other users that have grants to the source schema's objects in the source database do not exist in the target database."feedback=" : During the export, display to the screen, a dot (".") for every "n" records exported."consistent=" : "Y" means do not allow in-flight transactions to cause contents of tables to become inconsistent during the export."file=" : This is the name you give to the dump file. I usually use the format "..dump"."log=" : This is the name you give to the file that documents the progress (and errors, if applicable) that occur during the export. I usually use the format "_Exp.log"."owner=" : Name of source schema to export."userid=" : connect string for user officiating the export.

To import:
http://www.oracle.com/technology/products/text/x/Samples/Exp_Imp/index.html
Sample:
imp userid=samples/samples file=test.dmp show=n log=test.txt
imp sys/sys file=c:\dmp.dmp fromuser=user1 touser=userA

Sunday, April 27, 2008

starting Struts2

Compared with Struts1, Struts2 seems a little bit simplied regarding configuration files. However, there's something that needs our attention, which is the location of the struts.xml file.
This file should reside in the WEB-INF/classes directory instead of the WEB-INF directory.
It could also be put into a jar file in WEB-INF/lib directory.