Thursday, November 26, 2009

Use AXIS library to create web service and client

Download AXIS binary and extract it to your hard disk.
Set up AXIS2_HOME and path environment veriables.

Create service using WSDL file

1) Open terminal.

2) Go to the directory you want to create service.

3) Run the below command.

wsdl2java -uri "test.wsdl" -ss -sd -d xmlbeans -o service

4) This will create a folder called "service" and created the service using the .wsdl file.

5) Go to the "service" folder and run "ant" command to build the .aar file.

6) Go to AXIS bin and run "axis2server.sh".

7) Put the created .aar file into AXIS repository\services folder.

8) It will auto deployed as a service.

9) You can access the service using "http://127.0.0.1:8080".

Create client using WSDL file

1) Open terminal.

2) Go to the directory you want to create client.

3) Run the below command.

wsdl2java -uri "test.wsdl" -d xmlbeans -o client

4) This will create a folder called "client" and created the client code using the .wsdl file.

Wednesday, November 18, 2009

DNS Mapping in windows

Go to "C:\Windows\System32\drivers\etc".

Edit hosts file in etc folder. Add your ip addres and the mapping name.

Ex :-

192.168.4.7 name.domain.com

Now, you can access your ip address using DNS set above.

Ex :-

http://name.domain.com/App

Thursday, October 29, 2009

Embed document in html

embed a HTML document
<object data="data/test.html" type="text/html" width="300" height="200">
alt : <a href="data/test.html">test.html</a>
</object>

embed a pdf document
<object data="data/test.pdf" type="application/pdf" width="300" height="200">
alt : <a href="data/test.pdf">test.pdf</a>
</object>

embed a wav document
<object type="audio/x-wav" data="data/test.wav" width="200" height="20">
<param name="src" value="data/test.wav">
<param name="autoplay" value="false">
<param name="autoStart" value="0">
alt : <a href="data/test.wav">test.wav</a>
</object>

Tuesday, October 20, 2009

Clear clipboad using java script

Call this java script method to clear your clipboard in IE6. Sorry, it doesn't work in Mozilla and other browsers.

function clsClipsBrd(){
clipboardData.clearData();
}

Thursday, October 15, 2009

Create web service clients in java

There is a tool to create web service clients called as "cxf". This is a free tool. You must have the wsdl file to create java clients.

Download URL :- http://cxf.apache.org/download.html
User guide :- http://ws.apache.org/axis/java/user-guide.html
Reference :- http://cxf.apache.org/docs/wsdl-to-java.html

  • Extract cxf zip file and change directory to /din in your terminal
  • use the follwing command to create java clients
wsdl2java HelloWorld.wsdl

Namespace error in JAX-WS

Here is the error, i got when i am going to creat my web service client.

oracle.jdeveloper.webservices.model.WebServiceException: Error creating model from wsdl "http://127.0.0.1/Service.asmx?wsdl": undefined element declaration 's:schema'

I tried many ways to create my client using jdeveloper, but failed.

After that, i used axis web service for client implementation. It works fine in eclipse.

Create XML file in java

This is a simple example of creating standard XML file in java.

DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
Element rootElement = document.createElement("root");

This code segment creates a root element of the XML file.

Now, use this code to create child nodes to XML document.

Element em = document.createElement("element");
em.appendChild(document.createTextNode("data"));
rootElement.appendChild(em);