aspose file tools*
The moose likes Web Services and the fly likes asix2 client and windows based webservice interaction for unicode data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "asix2 client and windows based webservice interaction for unicode data" Watch "asix2 client and windows based webservice interaction for unicode data" New topic
Author

asix2 client and windows based webservice interaction for unicode data

Taggu Gupta
Greenhorn

Joined: Jul 13, 2010
Posts: 12
Hi ,

I’ve got an application which is deployed on Tomcat 6.0.29. I’ve created and deployed a webservice on IIS Web Service. The Web Method in this Webservice is used to get the file metadata (last_modified , last_accessed, last_created) from the Windows filesystem. The axis2 client is in java (jdk 1.6). If the filename path is in English then everything is OK. But, if one of the path component is in non-English(Chinese) then I get the following exception



Caused by: org.apache.axis2.AxisFault: Connection reset; nested exception is:

java.net.SocketException: Connection reset

at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:344)

at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:204)

... 24 more

Caused by: java.net.SocketException: Connection reset

at java.net.SocketInputStream.read(SocketInputStream.java:168)

at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)

at java.io.BufferedInputStream.read(BufferedInputStream.java:237)

at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77)

at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105)

at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1115)

at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832)

at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1590)

at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)

at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)

at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)

at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)

at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)

at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:541)

at org.apache.axis2.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:119)

at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:335)

... 25 more





The code in java looks like :





String xmlFile;

try {

FileAttribServiceStub stub = new FileAttribServiceStub();

FileAttribServiceStub.GetFileProperties request = new FileAttribServiceStub.GetFileProperties();

byte[] b = file.getCanonicalPath().getBytes();

String path = new String(b,"UTF-8");

//request.setFileName(file.getCanonicalPath());

request.setFileName(path);

// send and get the response

FileAttribServiceStub.GetFilePropertiesResponse response = stub //IT THROWS AN EXCEPTION HERE

.GetFileProperties(request);



String fileAttribXML = response.getGetFilePropertiesResult();



xmlFile = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";

xmlFile = xmlFile + "\n"

+ "<string xmlns=\"http://www.digitalmountain.com/webservices/\">";

xmlFile = xmlFile + "\n" + fileAttribXML;

xmlFile = xmlFile + "\n" + "</string>";





The Webservice code in .NET is :

sing System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Diagnostics;

using System.Web;

using System.Web.Services;

using System.Text;

using System.IO;



namespace WSFileProperties

{

/// <summary>

/// Summary description for Service1.

/// </summary>

///

[WebService(Namespace="http://www.digitalmountain.com/webservices/")]

public class FileAttribService : System.Web.Services.WebService

{

public FileAttribService()

{

//CODEGEN: This call is required by the ASP.NET Web Services Designer

InitializeComponent();

}



#region Component Designer generated code



//Required by the Web Services Designer

private IContainer components = null;



/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

}



/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if(disposing && components != null)

{

components.Dispose();

}

base.Dispose(disposing);

}



#endregion



// WEB SERVICE EXAMPLE

// The HelloWorld() example service returns the string Hello World

// To build, uncomment the following lines then save and build the project

// To test this web service, press F5



// [WebMethod]

// public string HelloWorld()

// {

// return "Hello World";

// }

[WebMethod]

public string GetFileProperties(string fileName)

{

StringBuilder sb = new StringBuilder();

if (Directory.Exists(fileName))

{

DateTime lstWriteTime = Directory.GetLastWriteTime(fileName);



sb.Append("<FileName name=" +"\"" + fileName + "\"" + ">");

sb.Append("<Created>" + Directory.GetCreationTime(fileName).ToString("u") + "</Created>");

sb.Append("<Modified>" + Directory.GetLastWriteTime(fileName).ToString("u") + "</Modified>");

sb.Append("<Accessed>" + Directory.GetLastAccessTime(fileName).ToString("u") + "</Accessed>");

sb.Append("</FileName>");



return sb.ToString();

}

if (File.Exists(fileName))

{

FileInfo fi = new FileInfo(fileName);

sb.Append("<FileName name=" +"\"" + fileName + "\"" + ">");

sb.Append("<Created>" + fi.CreationTime.ToString("u") + "</Created>");

sb.Append("<Modified>" + fi.LastWriteTime.ToString("u") + "</Modified>");

sb.Append("<Accessed>" + fi.LastAccessTime.ToString("u") + "</Accessed>");

sb.Append("</FileName>");



return sb.ToString();

}

if (!File.Exists(fileName) || Directory.Exists(fileName))

{

sb.Append("<FileName name=" +"\"" + fileName + "\"" + ">");

sb.Append("<Created>" + "null" + "</Created>");

sb.Append("<Modified>" + "null" + "</Modified>");

sb.Append("<Accessed>" + "null" + "</Accessed>");

sb.Append("</FileName>");



return sb.ToString();

}

return sb.ToString();

}



}







}





I’ve already installed the language path on my XP box. How should I go on resolving this.



Thanks,

Tarun


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: asix2 client and windows based webservice interaction for unicode data