Although Axis does technically support Vector, you should not use any
Java collections in your web service interface. If you want to support
interoperability, you should convert your collections to arrays.

Anne

On 7/27/05, Sreedhar Morangapally <[EMAIL PROTECTED]> wrote:
> Hi all, 
> I'm a novice in Web Services. I'm using Axis 1.2RC2 with Jakarta Tomcat
> 4.1.27 for creating Web Services. 
> Although I am able to run simple Calculator and other examples, I am unable
> to run the Web Services example which contain a method that return a Vector.
>  
> I know that Vector Class is supported by AXIS. 
> (http://ws.apache.org/soap/docs/guide/serializer.html)
>  
> I am providing the .jws file and the Client Program. Please help me.
>  
> My .jws file is as follows:- 
> ************ VitalMail.jws starts
> here****************************
> import java.util.Vector;
> import java.util.Properties; 
> import javax.mail.Folder;
> import javax.mail.Message;
> import javax.mail.Session;
> import javax.mail.Store; 
> 
> public class VitalMail
> {
>     String attachmentFound="";
>     
>     public Vector retrieveMail()
>     {
>         Vector a1 = new Vector();
>         
>         try
>         {
>             String hostName = "192.168.20.1";
>             String userName = "myUserName"; //not the Real :-)
>             String password = "myPassword"; //not the Real :-)
>             Properties prop = new Properties();
>             prop.setProperty("mail.smtp.host",hostName);
>             Session ses1 = Session.getDefaultInstance(prop, null);
>             Store store1 = ses1.getStore("pop3");
>             store1.connect(hostName, userName, password);
>             Folder folder1 = store1.getFolder("INBOX");
>             folder1.open(Folder.READ_ONLY);
>             Message msg[] = folder1.getMessages();
>             
>             for (int i=0, n= msg.length; i<n; i++) 
>             {
>                 if(msg[i].isMimeType("multipart/*")) 
>                 {
>                     attachmentFound = "A";
>                 }
>                 else
>                 {
>                     attachmentFound = " ";
>                 }
>               &nb sp; 
>                 System.out.println(attachmentFound + " " + i + ": " + msg
> [i].getFrom()[0] +"\t"+ msg [i].getSubject()+"\t"+ msg[i].getSentDate() +
> "\t"+ msg[i].getSize()+" Bytes\n");
>                 
>                 a1.add(attachmentFound);
>                 a1.add(i+"");
>                 a1.add(msg [i].getFrom()[0]);
>                 a1.add(msg [i].getSubject());
>                 a1.add(msg[i].getSentDate());
>                 a1.add(msg[i].getSize()+" Bytes");
>             }
>             folder1.close(false);
>             store1.close();
>         }
>         catch(Exception e)
>         {
>            
> System.out.println("*********************************************Exception
> while retrieving your Mails: "+e.getMessage());
>         }
>         return a1;
>     }
> }
> ************ VitalMail.jws ends
> here**************************** 
> 
> My Client Program to access the above web service is as follows:- 
> **************** Client Program starts here ********************
> package VitalMail;
> import org.apache.axis.client.Call;
> import org.apache.axis.client.Service;
> import org.apache.axis.utils.Options; 
> import java.util.Vector;
> import java.util.Iterator; 
> public class MailHelper
> {
>     public static void main(String[] args) throws Exception
>     {
>         try
>         {
>             Options options = new Options(args);
>             String endpoint = "http://localhost:"; + options.getPort() +
> "/axis/VitalMail.jws";
>             args = options.getRemainingArgs();
>             
>             String method = args[0];
>             
>             Service  service = new Service();
>             Call     call    = (Call) service.createCall();
>             
>             call.setTargetEndpointAddress(new java.net.URL(endpoint));
>             call.setOperationName( method );
>             //call.setReturnType(XMLType.XSD_ANY, Vector.class);
>             call.setReturnClass(Vector.class);
>             
>             Vector a1 = new Vector();
>             a1 = (Vector) call.invoke( new Object [] {});
>             Iterator itr = a1.iterator();
>             while(itr.hasNext())
>             {
>                 Object o = (Object) itr.next();
>                 System.out.println("Object: " + o);
>             }
>         }
>         catch(Exception e)
>         {
>             System.out.println("Exception: " + e);
>         }
>     }
> } 
> **************** Client Program ends here ******************** 
> I am running my Client program with an argument "retrieveMail". 
> I am getting the following Exception:- 
> Exception: org.xml.sax.SAXParseException: Document root element is missing.
> (Many more lines above this line) 
> 
> I think this Exception is quite often and I want to run a Web Service Client
> with return types other than the Java Primitive Types. 
>   
>   
> Thanks in advance, 
>   
> Sreedhar 
> Hyderabad
> 
>  ________________________________
>  Start your day with Yahoo! - make it your home page 
> 
>

Reply via email to