home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
wsgatsam.zip
/
CheckIn.java
< prev
next >
Wrap
Text File
|
2003-02-24
|
4KB
|
119 lines
/**
* %wsgw_sample_start%
* Licensed Materials - Property of IBM
*
* (c) Copyright IBM Corp. 2001, 2002 All Rights Reserved.
*
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with
* IBM Corp.
* %wsgw_sample_end%
*/
package services.lftfileservice;
import org.apache.wsif.util.*;
import org.apache.wsif.*;
import com.ibm.wsdl.extensions.lft.*;
import com.ibm.wsif.providers.lft.*;
import com.fileService.www.*;
public class CheckIn {
private static void doCheckIn (FileServicePort fs, String installDir)
throws Exception {
String fileName =
"file:"+installDir+"/samples/services/lftfileservice/demo.htm";
System.out.println("checkIn: File Name: "+fileName);
String message =
fs.checkIn("fileId001", "changed this changed that" , fileName);
System.out.println("CheckIn: Message : " + message);
}
/**
* Makes sure the pathName starts with one and only one '/'
* and ends with no '/'. Replaces '\' by '/'.
* @param pathName the path name
* @return the valid path name
*/
protected static String makeValidPathName(String pathName) {
// make sure there is only one '/' at start.
while (pathName.startsWith("/")) {
pathName = pathName.substring(1);
}
pathName = "/"+pathName;
// remove '/' at end.
while (pathName.endsWith("/")) {
pathName = pathName.substring(0,pathName.length()-1);
}
// Replace '\' by '/'
return pathName.replace('\\','/');
}
protected static void usage() {
System.out.println("The valid options are wsif, wsgw or java.");
}
public static void main (String[] args) throws Exception {
String portTypeName = "fileServicePort";
String portName=null;
String wsdlLocation=null;
String installDir=args[1].trim();
String gatewayHostPort=null;
System.out.println("Starting CheckIn...");
installDir = CheckIn.makeValidPathName(installDir);
//System.out.println("installDir is now: "+installDir);
if((args[0]==null)||(args[0].equals("wsif"))) {
portName = "HTTPRPort"; // Direct WSDL
wsdlLocation =
"file:"+installDir+"/samples/services/lftfileservice/LFTSample.wsdl";
} else if (args[0].equals("wsgw")) {
portName = "fileServicePortApacheAxisBindingPort"; // Axis GW
// TBD: It shouldn't be localhost here, but the actual hostname.
wsdlLocation = "http://localhost/wsgw/ServiceDefinition?name=fileService";
} else if (args[0].equals("java")) {
portName = "fileServicePortJavaBindingPort";
wsdlLocation =
"file:"+installDir+"/samples/services/lftfileservice/LFTSampleJava.wsdl";
} else {
System.out.println("This option ("+args[0]+") is not supported");
CheckIn.usage();
}
System.out.println("wsdlURL: " + wsdlLocation);
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service = factory.getService(
wsdlLocation,
null, // serviceNS
null, // serviceName
"http://www.fileService.com/largeFile", // portTypeNS
portTypeName); // portTypeName
FileServicePort fsStub = null;
if(portName != null) {
System.out.println ("\n\nUsing '" + portName + "' port:");
System.out.println("FileServicePort.class: "
+FileServicePort.class.toString());
fsStub =(FileServicePort)service.getStub(portName, FileServicePort.class);
if ( fsStub != null) {
doCheckIn (fsStub, installDir);
} else {
System.out.println( "fsStub is Null");
}
}
}
}