To create a deep copy of Java object you should implement "Cloneable" interface and override clone() method. Here is the sample code:
class MyClass implements Cloneable
{
public Object clone()
{
try
{
return super.clone();
}
catch(CloneNotSupportedException ex)
{
return null;
}
}
}
Tuesday, April 7, 2009
Java Object Clone Sample Code
Thursday, April 2, 2009
Accessing SAP XI Web Service through simple Axis 1 client
This a code for accessing SAP XI Web Service through Axis1, One can suggest Axis2 code for this.
Service service = new Service();
Call call = (Call) service.createCall();
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://sap.com/xi/WebService/soap1.1");
call.setEncodingStyle(null);
call.setOperationName("YOUR_OPERATION_NAME_IN_WSDL");
Options opts = new Options(args);
args = opts.getRemainingArgs();
if (args != null) {
opts.setDefaultURL(args[0]);
} else {
opts.setDefaultURL("YOUR_SERVICE_URL_IN_WSDL");
}
//if athonticated service set
call.setUsername("YOUR_USERNAME");
call.setPassword("YOUR_PASSWORD");
call.setTargetEndpointAddress(new URL(opts.getURL()));
//requestString is soap envelope as a string
SOAPEnvelope env = new SOAPEnvelope(new ByteArrayInputStream(requestString.getBytes()));
call.invoke(env);
Thursday, March 19, 2009
Castor - Open Source data binding framework for Java
You can use Castor java library to process WSDL files.
First you neet to download Castor library from http://www.castor.org/.
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
Definition definition = wsdlReader.readWSDL("C:/Temp/order.wsdl");
if (definition == null)
{
System.err.println("definition element is null");
System.exit(1);
}
Map servicesMap = definition.getServices();
....
..