How to access the sequence in Client file of Corba?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • user545
    New Member
    • Feb 2015
    • 1

    #1

    How to access the sequence in Client file of Corba?

    Code:
    IDL FILE
    module DirApp
    {
    typedef sequence<string> CompName;
    typedef sequence<string> CompNumber;
    typedef sequence<string> CompDetails;
    typedef sequence<string> rate;
     
    interface DirInterface{
    string getContact(in string name1,in CompName conam,in CompNumber conumb);
    
    string getDetails(in string name2,in CompName conam,in CompNumber conumb,in CompDetails cod,in rate r);
    
    void Rate(in rate r);
    
        oneway void shutdown();
    };
    };
    
    
    CLIENT FILE
    public class DirClient 
    {
      static DirInterface DirImpl;
      static int flag=1;
      static int k=0;
      
      public static void main(String args[])
       {
    
    
     
    
    CompName conam;
    conam.length(5);
           
        try{
                     System.out.println("\n----------------------------------------------");
    System.out.println("DirClient: Looking up DirServer...");
               
                    // create and initialize the ORB
                    ORB orb = ORB.init(args, null);
    
                    // get the root naming context
                    org.omg.CORBA.Object objRef = 
                    orb.resolve_initial_references("NameService");
    
                    // Use NamingContextExt instead of NamingContext. 
                    // This is part of the Interoperable naming Service.  
                    NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
    
                    // resolve the Object Reference in Naming
                    String name = "DirOperations";
                    DirImpl = DirInterfaceHelper.narrow(ncRef.resolve_str(name));
    
    System.out.print("DirClient: Obtained a handle on server object: \n\n");
    System.out.println(DirImpl);
    
                    Scanner sc=new Scanner(System.in);
          
                    flag=1;
    
                    do
                    {
                    
    
    System.out.println("1.add details and rate 2. get details 3.Get phone number  0.exit");
        int ch=sc.nextInt();
    
        switch(ch){
    case 1:
    System.out.println("Input  company name to add");
    conam[k]=sc.nextLine();
    
    System.out.println("Input  company details");
    cod[k]=sc.nextLine();
    
    System.out.println("input contact number of company");
    conumb[k]=sc.next();
    
    k++;
    
       break;
    
    
    case 2:
    
        System.out.println("Input company name to get its details");
    String name2=sc.next();
    
    String det=DirImp1.getDetails(name2,conam,conumb,cod,r);
        System.out.println(det);
        break;
    
    
    
    case 3:
        System.out.println("Enter name of the company to get contact number");
    String name1=sc.next();
    
        String xx=DirImp1.getContact(name1,conam,conumb);
        System.out.println(xx);break;
    
    
    
    
    
     case 0:System.exit(0);
    
    
        }
    
              }while (ch!=0);
    
    
     DirImpl.shutdown();
             }
                catch (Exception e) 
                {   
                     //System.err.println("ERROR: " + e);   
                     //e.printStackTrace(System.out);   
                     System.out.println("\n----------------------------------------------");
    System.out.println("DirClient: Some Error Has Occurred !");
                     System.out.println("\n----------------------------------------------");
                }
    
    System.out.println("\n DirServer: Exiting...");
    System.out.println("\n----------------------------------------------");
            }
    }
    Why won't the client file compile when i try to access the typedef that i created in idl file?
    what changes should I make in syntax


    Error:
    expected';'
    cannot find symbol connam
Working...