Java - Web Service

Java - Web Service

Hi,

I wanted a simple java program for web services development as per below:

------ IN REQUEST ------ <FileName>

FileName - Path of the file (For example: C/text.txt)

------ IN RESPONSE --------

<FileName> <Size> <Type> <ReadAccess> <WriteAccess> <LastModified>

FileName: This should be filename same as input. Size: size of the file in KB. Type: Type of the file i.e. Java File, ..or anything like. ReadAccess and WriteAccess: Boolean - True or false depending upon access rights. LastModified - Timestamp in the format ddMMyyyy'T'hhmmss

Please help me to get this done.

Thanks

View Answers

May 12, 2012 at 5:53 PM

Hi Thanks :)

But I wanted to use this program to create a WSDL file.

I wanted my Web Service request message as

print("<getFileDetailsRequest><file>--Here goes path of a file--</file></getFileDetailsRequest>"); >

Here file is string.


May 12, 2012 at 4:16 PM

The given code allow the user to input file name with path. The code will then determine the size of file, name of file, last modified date of file. It also check whether the given file is readable or writable.

import javax.swing.*;
import java.util.*;
import java.text.*;
import java.io.*;

public class FileOperations{
    public static void main(String[]args){
       File f=new File("c:/data.txt");
       long size=f.length();
       String name=f.getName();
       JFileChooser chooser = new JFileChooser();
       String fileType= chooser.getTypeDescription(f);
       boolean check1=f.canRead();
       boolean check2=f.canWrite();
       long s=f.lastModified();
       Date d=new Date(s);
       SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
       String lastmodified=sdf.format(d);

       System.out.println("File Name: "+name);
       System.out.println("File Type: "+fileType);
       System.out.println("Is file Readable: "+check1);
       System.out.println("Is file Writable: "+check2);
       System.out.println("Last Modified Date: "+lastmodified);
    }
}

May 12, 2012 at 6:07 PM

And this request message should return response as

print("<getFileDetailsResponse><fileName>--Name of the file --</fileName><type>--File type--</type><size>--size of the file--</size><isReadable>--boolean--<isReadable><isWritable>--boolean--</isWritable><lastModified>--timestamp--</lastModified></getFileDetailsResponse>");

Ads









Related Tutorials/Questions & Answers:
Fax service in Java application.
Fax service in Java application.  Hello, I want to develop a Java application to send fax to any destination fax numbers. Anyone who knows about this, please tell how I can do this. Is there any free libraries
Running Java Applications as a Windows Service
Running Java Applications as a Windows Service  sample code for "Run a Java application as a Windows Service
Advertisements
Version of com.bushidowallet>bushido-java-service dependency
List of Version of com.bushidowallet>bushido-java-service dependency
Version of com.monarchapis>service-java-driver dependency
List of Version of com.monarchapis>service-java-driver dependency
minor project on service center management in core java
minor project on service center management in core java  I need a minor project on service center management in core java...If u have then plz send me
Version of com.monarchapis>service-api-java-driver dependency
List of Version of com.monarchapis>service-api-java-driver dependency
Maven Dependency bushido-java-service >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.bushidowallet >> bushido-java-service version1.0.0 in your project
Maven Dependency bushido-java-service >> 1.0.1
You should include the dependency code given in this page to add Maven Dependency of com.bushidowallet >> bushido-java-service version1.0.1 in your project
Maven Dependency bushido-java-service >> 1.0.3
You should include the dependency code given in this page to add Maven Dependency of com.bushidowallet >> bushido-java-service version1.0.3 in your project
Maven Dependency service-java-driver >> 0.8.2
You should include the dependency code given in this page to add Maven Dependency of com.monarchapis >> service-java-driver version0.8.2 in your project
java program for Denial of Service (DoS) attacks detection - Swing AWT
java program for Denial of Service (DoS) attacks detection  i want a simple program to generate and detect a Denial of Service (DoS) attacks. using java program
Java Message Service(JMS)
Java Message Service(JMS)       JMS (Java Message Service) is a Java API that allows java... other. Java package "javax.jms" provides JMS api. To use JMS, one
Maven Dependency service-api-java-driver >> 0.8.1
You should include the dependency code given in this page to add Maven Dependency of com.monarchapis >> service-api-java-driver version0.8.1 in your project
Need simple java code to start and stop the remote windows service.
Need simple java code to start and stop the remote windows service.  Hi, I Need simple java code to start and stop the remote windows service... is running on Server A,I want to close that service i.e notepad.exe from my remote
Mocking a service that calls another service
Mocking a service that calls another service  I have a method, say m1 in class, say C1. Method m1 calls a method, say m2 from another service class, say C2. So I mock m2 in junit test-cases for m1. However, m2 itself calls
service
ModuleNotFoundError: No module named 'as-a-service'
ModuleNotFoundError: No module named 'as-a-service'  Hi, My Python... 'as-a-service' How to remove the ModuleNotFoundError: No module named 'as-a-service' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'as-a-service'
ModuleNotFoundError: No module named 'as-a-service'  Hi, My Python... 'as-a-service' How to remove the ModuleNotFoundError: No module named 'as-a-service' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'service'
ModuleNotFoundError: No module named 'service'  Hi, My Python... 'service' How to remove the ModuleNotFoundError: No module named 'service... to install padas library. You can install service python with following command
unable to open the service tomcat5
unable to open the service tomcat5  While trying to run tomcat server getting "unable to open the service tomcat5" error after installed tomcat
restart elasticsearch service centos
restart elasticsearch service centos  Hi I have elasticsearch server on Centos. How to restart elasticsearch service centos? Thanks   Hi, In centos elasticserch is installed as service. It can be restarted
MongoDB uninstall windows service
the MongoDB on my Winodws Computer as service. Now I want to uninstall the mongodb from windows service. Can any one tell me How to uninstall the MongoDB from windows server? Thanks   Hi, You can remove the MongoBD service using
What is the default cache service of hibernate?
What is the default cache service of hibernate?  Hi, What is the default cache service of hibernate? Thanks
Version of com.disdar>extraction-service dependency
List of Version of com.disdar>extraction-service dependency
Version of com.intersult>abraxas-service dependency
List of Version of com.intersult>abraxas-service dependency
Version of com.ricardoespsanto>onesky-service dependency
List of Version of com.ricardoespsanto>onesky-service dependency
Version of com.sdl>odata_service dependency
List of Version of com.sdl>odata_service dependency
Version of com.shipdream>service-core dependency
List of Version of com.shipdream>service-core dependency
Version of com.tsc9526>monalisa-service dependency
List of Version of com.tsc9526>monalisa-service dependency
ModuleNotFoundError: No module named 'aio-service'
ModuleNotFoundError: No module named 'aio-service'  Hi, My Python... 'aio-service' How to remove the ModuleNotFoundError: No module named 'aio-service' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'async-service'
ModuleNotFoundError: No module named 'async-service'  Hi, My... 'async-service' How to remove the ModuleNotFoundError: No module named 'async-service' error? Thanks   Hi, In your python

Ads