To start with WCF you must read this article
Introducing Windows Communication Foundation in .NET Framework 4
This Blog is first of all memos for me!! From time to time I get exposed to new and cool stuff for developers and architects ,most of the time its a solution for a problem or tips or tricks, so, I would like to track my memos and share it with you, it can save your time and nervous, I hope you will enjoy it - by Yaniv Tzanany.
Search This Blog
Thursday, November 25, 2010
Monday, November 22, 2010
Speeding Up Your Web Site
one of the complete guide how to Speeding Up Your Web Site.
http://developer.yahoo.com/performance/rules.html
http://developer.yahoo.com/performance/rules.html
Sunday, November 21, 2010
The Essentials of Filters in j2ee
A filter dynamically intercepts requests and responses to transform or use the information contained in the requests or responses. Filters typically do not themselves create responses, but instead provide universal functions that can be "attached" to any type of servlet or JSP page.
Filters are important for a number of reasons. First, they provide the ability to encapsulate recurring tasks in reusable units. Organized developers are constantly on the lookout for ways to modularize their code. Modular code is more manageable and documentable, is easier to debug, and if done well, can be reused in another setting.
All the great article and sample could be found here The Essentials of Filters.
Must read a pdf file SERVLET AND JSP FILTERS
more sample catalog JAVA servlet / filter samples
enjoy
Yaniv
Filters are important for a number of reasons. First, they provide the ability to encapsulate recurring tasks in reusable units. Organized developers are constantly on the lookout for ways to modularize their code. Modular code is more manageable and documentable, is easier to debug, and if done well, can be reused in another setting.
All the great article and sample could be found here The Essentials of Filters.
Must read a pdf file SERVLET AND JSP FILTERS
more sample catalog JAVA servlet / filter samples
enjoy
Yaniv
Monday, November 15, 2010
How to consume WCF service from Java - step by step
Here is a step by step sample how to consume WCF service from java.
WCF in VS.NET (2008 in my case):
create a new project
file->new->project->web->wcf service application
leave the default settings as is , a new WCF service created by the wizard called Service1.svc.
press F5 -> make sure you can see the service page http://localhost:2813/Service1.svc and his wsdl file
http://localhost:2813/Service1.svc?wsdl.
to connect from java to WCF service we have to change the binding type from the default "wsHttpBinding" to "basicHttpBinding".
to do that , edit the Web.config file
change the end point to somthing like this :
<endpoint address="" binding="basicHttpBinding" bindingconfiguration="Binding1" contract="WcfService1.IService1"> </endpoint>
add the next binding section ( you can change it as you like)
<bindings>
<basicHttpBinding>
<binding name="Binding1"
hostNameComparisonMode="StrongWildcard"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
openTimeout="00:10:00"
closeTimeout="00:10:00"
maxReceivedMessageSize="65536"
maxBufferSize="65536"
maxBufferPoolSize="524288"
transferMode="Buffered"
messageEncoding="Text"
textEncoding="utf-8"
bypassProxyOnLocal="false"
useDefaultWebProxy="true" >
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
press F5 -> make sure you can see the service page after the changes http://localhost:2813/Service1.svc and his wsdl file http://localhost:2813/Service1.svc?wsdl
JAVA side:
open cmd window
cd to your axis2/bin directory , cd C:\Program Files\Apache Software Foundation\axis2-1.5.2\bin
create directory test in the bin folder , mkdir test.
run the next batch file from your bin directory
wsdl2java.bat -o test -uri http://localhost:2813/Service1.svc?wsdl
the above command should generate the java stub to connect to your wcf service.
Service1CallbackHandler.java and Service1Stub.java.
add those file into your java test program and create your test function.
public static void CallWCFService()
{
try {
Service1Stub srv1 = new Service1Stub();
srv1._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
Service1Stub.GetData data = new Service1Stub.GetData();
data.setValue(44);
Service1Stub.GetDataResponse reposne = srv1.getData(data);
System.out.println(reposne.getGetDataResult());
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if you will remark the yellow line (enable the chunk), you will get the
org.apache.axis2.AxisFault: The input stream for an incoming message is null.
when i disabled the chunk , it works perfect.
i would like to say a special thanks to Yaron Naveh , that guide & helped me to get this works,Yaron have a very informative blog on this subject too, thanks Yaron !!!
From Microsoft article (http://msdn.microsoft.com/library/ee958158.aspx)
“For communication with the Java EE-based reservation application, a binding that uses standard SOAP on the wire is required. If the application and the platform it runs on support some or all of the WS-* specifications, the endpoint used by this client might choose WsHttpBinding. This would allow reliable, secure, and transactional communication between the two applications.
If this application and the platform it runs on support only standard SOAP matching the WS-I Basic Profile, however, the endpoint it uses to access the rental car reservation application would use BasicHttpBinding. If transport security is required, this binding could be configured to use HTTPS instead of plain HTTP.”
enjoy
Yaniv Tzanany
WCF in VS.NET (2008 in my case):
create a new project
file->new->project->web->wcf service application
leave the default settings as is , a new WCF service created by the wizard called Service1.svc.
press F5 -> make sure you can see the service page http://localhost:2813/Service1.svc and his wsdl file
http://localhost:2813/Service1.svc?wsdl.
to connect from java to WCF service we have to change the binding type from the default "wsHttpBinding" to "basicHttpBinding".
to do that , edit the Web.config file
change the end point to somthing like this :
<endpoint address="" binding="basicHttpBinding" bindingconfiguration="Binding1" contract="WcfService1.IService1"> </endpoint>
add the next binding section ( you can change it as you like)
<bindings>
<basicHttpBinding>
<binding name="Binding1"
hostNameComparisonMode="StrongWildcard"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
openTimeout="00:10:00"
closeTimeout="00:10:00"
maxReceivedMessageSize="65536"
maxBufferSize="65536"
maxBufferPoolSize="524288"
transferMode="Buffered"
messageEncoding="Text"
textEncoding="utf-8"
bypassProxyOnLocal="false"
useDefaultWebProxy="true" >
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
press F5 -> make sure you can see the service page after the changes http://localhost:2813/Service1.svc and his wsdl file http://localhost:2813/Service1.svc?wsdl
JAVA side:
open cmd window
cd to your axis2/bin directory , cd C:\Program Files\Apache Software Foundation\axis2-1.5.2\bin
create directory test in the bin folder , mkdir test.
run the next batch file from your bin directory
wsdl2java.bat -o test -uri http://localhost:2813/Service1.svc?wsdl
the above command should generate the java stub to connect to your wcf service.
Service1CallbackHandler.java and Service1Stub.java.
add those file into your java test program and create your test function.
public static void CallWCFService()
{
try {
Service1Stub srv1 = new Service1Stub();
srv1._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED,Boolean.FALSE);
Service1Stub.GetData data = new Service1Stub.GetData();
data.setValue(44);
Service1Stub.GetDataResponse reposne = srv1.getData(data);
System.out.println(reposne.getGetDataResult());
} catch (AxisFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if you will remark the yellow line (enable the chunk), you will get the
org.apache.axis2.AxisFault: The input stream for an incoming message is null.
when i disabled the chunk , it works perfect.
i would like to say a special thanks to Yaron Naveh , that guide & helped me to get this works,Yaron have a very informative blog on this subject too, thanks Yaron !!!
From Microsoft article (http://msdn.microsoft.com/library/ee958158.aspx)
“For communication with the Java EE-based reservation application, a binding that uses standard SOAP on the wire is required. If the application and the platform it runs on support some or all of the WS-* specifications, the endpoint used by this client might choose WsHttpBinding. This would allow reliable, secure, and transactional communication between the two applications.
If this application and the platform it runs on support only standard SOAP matching the WS-I Basic Profile, however, the endpoint it uses to access the rental car reservation application would use BasicHttpBinding. If transport security is required, this binding could be configured to use HTTPS instead of plain HTTP.”
enjoy
Yaniv Tzanany
Sunday, November 14, 2010
Rampart FAQ and Web services stuff
Rampart = WS-Security module of Axis2.
in this blog you can find a very good FAQ about Rampart module , from basic to advanced stuff.
this link can be useful too , http://blog.rampartfaq.com/.
great blog on Web Services Security, Interoperability and Performance - WCF, Axis2, WSIT
enjoy
in this blog you can find a very good FAQ about Rampart module , from basic to advanced stuff.
this link can be useful too , http://blog.rampartfaq.com/.
great blog on Web Services Security, Interoperability and Performance - WCF, Axis2, WSIT
enjoy
Using embedded DerbyDB
first i created the DB , using the ij tool .
i jar the db directory file into one jar file (dbs.jar).
i add to my class path the derby.jar file and dbs.jar.
i used the next method call
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
DriverManager.getConnection("jdbc:derby:classpath:mydb",m_connectionProperties);
if you want to run a script programmticly ,
The Derby Tools Library(derbytools.jar) contains a class named 'ij' which provides a static method called 'runScript'. This is the key to accomplishing what you want.
NOTE: The 'runScript' method returns the number of errors that occurred during the execution of the script.
http://db.apache.org/derby/javadoc/publishedapi/jdbc4/org/apache/derby/tools/ij.html
enjoy
Yaniv T
i jar the db directory file into one jar file (dbs.jar).
i add to my class path the derby.jar file and dbs.jar.
i used the next method call
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
DriverManager.getConnection("jdbc:derby:classpath:mydb",m_connectionProperties);
if you want to run a script programmticly ,
The Derby Tools Library(derbytools.jar) contains a class named 'ij' which provides a static method called 'runScript'. This is the key to accomplishing what you want.
NOTE: The 'runScript' method returns the number of errors that occurred during the execution of the script.
http://db.apache.org/derby/javadoc/publishedapi/jdbc4/org/apache/derby/tools/ij.html
enjoy
Yaniv T
Apache DerbyDB
DB is a Project of the Apache Software Foundation, charged with the creation and maintenance of commercial-quality, open-source, database solutions based on software licensed to the Foundation, for distribution at no charge to the public.
I got the chance to test it and play with it,, as embedded db in my app.
i wrote some notes so i would like to share with you.
to start the db:
cd D:\MyStuff\R_and_D\DerbyDB\db-derby-10.6.2.1-bin\DERBYTUTOR
set DERBY_HOME=D:\MyStuff\R_and_D\DerbyDB\db-derby-10.6.2.1-bin
set PATH=%DERBY_HOME%\bin;%PATH%
setEmbeddedCP.bat
java -jar %DERBY_HOME%\lib\derbyrun.jar ij
CONNECT 'jdbc:derby:mydb;create=true';
running script
run 'cmd.sql';
disconnect
connect 'jdbc:derby:alis;shutdown=true';
Mapping of java.sql.Types to SQL types
http://download.oracle.com/javadb/10.3.3.0/ref/rrefjdbc20377.html
Derby data types
http://db.apache.org/derby/docs/dev/ref/crefsqlj31068.html
online manual
http://db.apache.org/derby/manuals/#docs_10.6
Derby supports the following formats for TIMESTAMP:
yyyy-mm-dd hh:mm:ss[.nnnnnn]
yyyy-mm-dd-hh.mm.ss[.nnnnnn]
Derby Date Format:
yyyy-mm-dd
mm/dd/yyyy
dd.mm.yyyy
DATE Test
create table tmstp (c1 DATE);
valid query:
insert into tmstp values ('1990-03-22 10:00:00');
insert into tmstp values ('05/23/2005');
Tuning
from ij command we run the next command
call SYSCS_UTIL.SYSCS_COMPRESS_TABLE('APP','T_X',0);
commit;
CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('APP', 'T_X', null);
execution plan ->tuning
-- turn on RUNTIMESTATISTICS for connection:
CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1);
-- execute complex query here -- step through the result set
-- access run time statistics information:
VALUES SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS();
CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(0);
I got the chance to test it and play with it,, as embedded db in my app.
i wrote some notes so i would like to share with you.
to start the db:
cd D:\MyStuff\R_and_D\DerbyDB\db-derby-10.6.2.1-bin\DERBYTUTOR
set DERBY_HOME=D:\MyStuff\R_and_D\DerbyDB\db-derby-10.6.2.1-bin
set PATH=%DERBY_HOME%\bin;%PATH%
setEmbeddedCP.bat
java -jar %DERBY_HOME%\lib\derbyrun.jar ij
CONNECT 'jdbc:derby:mydb;create=true';
running script
run 'cmd.sql';
disconnect
connect 'jdbc:derby:alis;shutdown=true';
Mapping of java.sql.Types to SQL types
http://download.oracle.com/javadb/10.3.3.0/ref/rrefjdbc20377.html
Derby data types
http://db.apache.org/derby/docs/dev/ref/crefsqlj31068.html
online manual
http://db.apache.org/derby/manuals/#docs_10.6
Derby supports the following formats for TIMESTAMP:
yyyy-mm-dd hh:mm:ss[.nnnnnn]
yyyy-mm-dd-hh.mm.ss[.nnnnnn]
Derby Date Format:
yyyy-mm-dd
mm/dd/yyyy
dd.mm.yyyy
DATE Test
create table tmstp (c1 DATE);
valid query:
insert into tmstp values ('1990-03-22 10:00:00');
insert into tmstp values ('05/23/2005');
Tuning
from ij command we run the next command
call SYSCS_UTIL.SYSCS_COMPRESS_TABLE('APP','T_X',0);
commit;
CALL SYSCS_UTIL.SYSCS_UPDATE_STATISTICS('APP', 'T_X', null);
execution plan ->tuning
-- turn on RUNTIMESTATISTICS for connection:
CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1);
-- execute complex query here -- step through the result set
-- access run time statistics information:
VALUES SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS();
CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(0);
Sunday, November 7, 2010
IE9 for developers - what new
Yesterday i went to a session at Microsoft office, whats new in IE9, and how developers should prepared for this version.
its looks like IE9 its all about standard , HTML5 & CSS3 & SVG & performance boost , clean UI.
i understood that you could install this version only on OS VISTA and above , no XP.
i saw some nice feature from this beta browser , You can download the slide deck and demos from the lecturer site -> IE9 for Web Developers Slide Deck and Demos.
enjoy
Yaniv T
its looks like IE9 its all about standard , HTML5 & CSS3 & SVG & performance boost , clean UI.
i understood that you could install this version only on OS VISTA and above , no XP.
i saw some nice feature from this beta browser , You can download the slide deck and demos from the lecturer site -> IE9 for Web Developers Slide Deck and Demos.
enjoy
Yaniv T
Subscribe to:
Posts (Atom)