home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wsgatsam.zip / CheckOut.java < prev    next >
Text File  |  2003-02-24  |  3KB  |  79 lines

  1. /**
  2.  * %wsgw_sample_start%
  3.  * Licensed Materials - Property of IBM  
  4.  *    
  5.  * (c) Copyright IBM Corp. 2001, 2002 All Rights Reserved.  
  6.  *    
  7.  * US Government Users Restricted Rights - Use, duplication or   
  8.  * disclosure restricted by GSA ADP Schedule Contract with   
  9.  * IBM Corp.  
  10.  * %wsgw_sample_end%
  11.  */
  12.  
  13. package services.lftfileservice;
  14.  
  15. import org.apache.wsif.util.*;
  16. import org.apache.wsif.*;
  17. import com.ibm.wsdl.extensions.lft.*;
  18. import com.ibm.wsif.providers.lft.*;
  19. import com.fileService.www.*;
  20. import com.ibm.httpr.lft.LargeFileUtils;
  21.  
  22. public class CheckOut {
  23.  
  24.   private static void doCheckOut (FileServicePort fs) throws Exception {
  25.     String fileReference = fs.checkOut ("fileId001");
  26.     System.out.println("CheckOut : fileReference : " + fileReference);
  27.     System.out.println("CheckOut : fileReferenceURL : "
  28.                        + LargeFileUtils.getURLFromFileReference(fileReference));
  29.   }
  30.  
  31.   public static void main (String[] args) throws Exception {
  32.     String portTypeName = "fileServicePort";
  33.     String portName=null;
  34.     String wsdlLocation=null;
  35.     String installDir = args[1].trim();
  36.  
  37.     System.out.println("Starting CheckOut...");
  38.  
  39.     installDir = CheckIn.makeValidPathName(installDir); 
  40.  
  41.     if((args[0]==null)||(args[0].equals("wsif"))) {
  42.       portName = "HTTPRPort"; // Direct WSDL
  43.       wsdlLocation =
  44.         "file:"+installDir+"/samples/services/lftfileservice/LFTSample.wsdl";
  45.  
  46.     } else if (args[0].equals("wsgw")) {
  47.       portName = "fileServicePortApacheAxisBindingPort"; // Axis GW
  48.  
  49.       // TBD: It shouldn't be localhost here, but the actual hostname.
  50.       wsdlLocation = "http://localhost/wsgw/ServiceDefinition?name=fileService";        
  51.  
  52.     } else if (args[0].equals("java")) {
  53.       portName = "fileServicePortJavaBindingPort"; 
  54.       wsdlLocation =
  55.        "file:"+installDir+"/samples/services/lftfileservice/LFTSampleJava.wsdl";
  56.  
  57.     } else {
  58.       System.out.println("This option ("+args[0]+") is not supported");
  59.       CheckIn.usage();
  60.     }
  61.  
  62.     WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  63.     WSIFService service = factory.getService(
  64.       wsdlLocation, 
  65.       null,                                                   // serviceNS
  66.       null,                                                   // serviceName
  67.       "http://www.fileService.com/largeFile",                 // portTypeNS
  68.       portTypeName);                                          // portTypeName
  69.  
  70.     FileServicePort fsStub = null;
  71.     
  72.     if(portName != null) {
  73.       System.err.println ("\n\nUsing '" + portName + "' port:");
  74.       fsStub =(FileServicePort)service.getStub(portName, FileServicePort.class);
  75.       doCheckOut (fsStub);
  76.     } 
  77.   }
  78. }
  79.