0

hey,
i am working on a web services (WS) program. i have a method in the server that reads text file and store every line of text in to a string array.
on the client side, when i call the method it shows me that the value being retuned is String but not a string array (String[])
help why am i unable to return array from the server to the client


thank you!!!!

SERVER

import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import java.io.*;
import java.lang.String;


@WebService()
public class Customer {


    /**
     * Web service operation
     */
    @WebMethod(operationName = "openFile")
    public String[] openFile(@WebParam(name = "fileName")
    String fileName) {

        int num = 0;
        int i =0;
        String str="";
        String[] name=new String[200];


        try  {
            BufferedReader bufeinp = new BufferedReader( new FileReader("customers/"+fileName+".txt"));
            while ((str = bufeinp.readLine()) !=null){
              name[i] =str;
              i++;
              ++num;
          }
          bufeinp.close();
        }
        catch(IOException e)
        {
            System.err.println("Exception: " + e.getMessage());
            System.exit(1);
        }

     return name;

    }
}

CLIENT

private cust.CustomerService service = new cust.CustomerService();
    private cust.Customer port = service.getCustomerPort();
//this part gives me error
         String[] array = port.displayNames();
2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by gedas
0

I'm not familiar with WS, but what's the connection between displayNames() that you call on the client and openFile that you define on the server?

0

im a sorry i displayed wrong code for the client.

this is how the client actually should look like

private cust.CustomerService service = new cust.CustomerService();
    private cust.Customer port = service.getCustomerPort();
//this part gives me error
         String[] array = port.openFile(fileName)

thank you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.