Thursday, May 7, 2009

WSDL

Wsdl file is a xml file which describes the remote web service, i.e operations, parameters, return types , transports, bindings, and how to access the service.
To understand those we have to have a clear idea about the elements in the wsdl file. Following describes them one by one.

definition element
- The root element of all wsdl documents is the definitions element, which encapsulates the entire document and also provides a wsdl document with its name.
- Contains several xml namespace declarations.,
- among the namespaces one for the namespace of the wsdl 1.1 xml schema "http://schemas.xmlsoap.org/wsdl/" - declaring the wsdl namespace as the default namespace avoids having to qualify every wsdl element explicitly , with a prefix.
- also declares a 'targetNamespace' attribute.
- The 'message, portType, binding' elements are assigned lables using their 'name' attribute; these lables automatically ntake on the namespace specified by the 'targetNamespace' attribute.

types element
- serves as a container for defining any data types that are not describes by the xml schema built-in types: complex tyeps and custom simple types
- The data types and elements defined here are used by message definitionswhen declaring the parts ( payload) of the message

message element

Friday, October 31, 2008

Can't open disc C and D etc by doble clicking

If you encounterd the above problem , solution is the following

go to command prompt and write this command
c:\> attrib -r -s -h autorun.inf
c:\> del autorun.inf
d:\> attrib -r -s -h autorun.inf
d:\> del autorun.inf
restart the pc

:)

Wednesday, October 29, 2008

Setting Path in Debian GNU Linux

When we are developing using java we need to set path in our environment. Not only for this some other applications will also need the path to be set manually. There are 2 ways of setting path permenently in Debian GNU linux.

1. Setting path using \etc\env file.
First of all we need to find the current path for normal users and root users.

using shell we can find it as
echo $PATH
then copy the path and past it to the 'env' file in the \etc folder. (Here you need Root privileges)
Then append the path for your java installation .
I'll post an example sooner for this.

Monday, October 20, 2008

Project Developed With NetBeans IDE

Project : Dynamic User Interface Creation for Web Services.

This is my final year project for the graduation in University Of Peradeniya Sri Lanka. For the Entire project NetBeans helped me a lot ( from coding to building the project) . I used Axis2 for my project. In my project User Interfaces for both web services having simple and complex data type argument addressed. Steps involved are:
1. parse the wsdl file (jaxp is used )
2. based on the parsed output html dynamic interface creation
3. invocation of the remote web service
4. getting the result
5. displaying the result

As this is a web based JSP is extensively used throughout the project. NetBeans took big burden away with its glue with jsp technology and ability to build the project from the source without allowing us to manullay ANT build it. Thanks NetBeans for it. HAPPY 10th BirthDay !!!

Friday, March 23, 2007

Invoking a Axis2 service which has complex parameters

I have found a very nice article from the following site.
http://people.apache.org/~thilina/axis2/docs/pojoguide.html

Invoking Axis2 web service dynamically

Using Axis2 client api you can easily invoke an Axis2 web service easily. Steps are described below

First you have to create and deploy a service. For simplicity I create a service which echos.

public class SimpleService
{
public String echo(String msg)
{
return msg;
} //end of method echo
} //end of class SimpleService

Compile the java file and get the SimpleService.class file
2.Now we have to package it as an axis service
now create a file called services.xml
services.xml should contain the following lines of code

<service name="SimpleService">

<description>

This service is to get the running Axis version

</description>

<parameter name="ServiceClass">SimpleService</parameter>

<operation name="echo">

<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />

</operation>

</service>

Axis2 expects services to be packaged accoring to a certain format.The package muct be a .jar file with the compiled java classes and a META-INF directory which will hold the services.xml file. The jar file can be name .aar to distinguish it as an Axis2 service archive. It's important to note that the part of the file name before .aar is the service name. Create a temp directory in the same location where the SimpleService.java file exists

[Linux]
mkdir temp

Now compile the SimpleService.java class and move the SimpleService.class file to the temp directory

javac SimpleService.java -d temp/

create a META-INF directory within the "temp" directory and copy the service.xml file inot the META-INF directory. Change directory to the temp directory and user the jar command as follows to creat ehe srevice archive named SimplService .aar

jar -cvf SimpleService.aar *

Here i'm using the simple Http server comes with Axis2. Now put the created archive into the services directory , which resides in the repository directory.

Now start the server
[linux]
cd bin
sh axis2server.sh

now open a web browser and you can find the service just deployed when entering the url
http://localhost:8080/axis2 int to the web browser.

Invoking the service dynamically

package kan;

import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

public class SimpleServiceClient {
public static void main(String[] args1) throws AxisFault {
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR = new EndpointReference( "http://localhost:8080/axis2/services/SimpleService");
options.setTo(targetEPR);
QName opecho = new QName("http://ws.apache.org/axis2", "echo");
Object[] args = new Object[1] ;
args[0] = new String("Hell0 I'm Kanchana");
System.out.println(serviceClient.invokeBlocking(opecho,args));
}//end of main
}//end of class