| 1 |
package samples.transport ; |
| 2 |
|
| 3 |
import org.apache.axis.client.Call; |
| 4 |
import org.apache.axis.client.Service; |
| 5 |
import org.apache.axis.configuration.XMLStringProvider; |
| 6 |
import org.apache.axis.deployment.wsdd.WSDDConstants; |
| 7 |
import org.apache.axis.encoding.XMLType; |
| 8 |
import org.apache.axis.utils.Options; |
| 9 |
|
| 10 |
import javax.xml.namespace.QName; |
| 11 |
import javax.xml.rpc.ParameterMode; |
| 12 |
|
| 13 |
/** Tests the simple File transport. To run: |
| 14 |
* java org.apache.axis.utils.Admin client client_deploy.xml |
| 15 |
* java org.apache.axis.utils.Admin server deploy.xml |
| 16 |
* java samples.transport.FileTest IBM |
| 17 |
* java samples.transport.FileTest XXX |
| 18 |
*/ |
| 19 |
|
| 20 |
public class FileTest { |
| 21 |
static final String wsdd = |
| 22 |
"<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " + |
| 23 |
"xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n" + |
| 24 |
" <transport name=\"FileTransport\" pivot=\"java:samples.transport.FileSender\"/>\n" + |
| 25 |
" <service name=\"" + WSDDConstants.URI_WSDD + "\" provider=\"java:MSG\">\n" + |
| 26 |
" <parameter name=\"allowedMethods\" value=\"AdminService\"/>\n" + |
| 27 |
" <parameter name=\"className\" value=\"org.apache.axis.utils.Admin\"/>\n" + |
| 28 |
" </service>\n" + |
| 29 |
"</deployment>"; |
| 30 |
|
| 31 |
public static void main(String args[]) throws Exception { |
| 32 |
FileReader reader = new FileReader(); |
| 33 |
reader.setDaemon(true); |
| 34 |
reader.start(); |
| 35 |
|
| 36 |
Options opts = new Options( args ); |
| 37 |
|
| 38 |
args = opts.getRemainingArgs(); |
| 39 |
|
| 40 |
if ( args == null ) { |
| 41 |
System.err.println( "Usage: GetQuote <symbol>" ); |
| 42 |
System.exit(1); |
| 43 |
} |
| 44 |
|
| 45 |
String symbol = args[0] ; |
| 46 |
Service service = new Service(new XMLStringProvider(wsdd)); |
| 47 |
Call call = (Call) service.createCall(); |
| 48 |
|
| 49 |
call.setOperationName( new QName("urn:xmltoday-delayed-quotes", "getQuote") ); |
| 50 |
call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN ); |
| 51 |
call.setReturnType( XMLType.XSD_FLOAT ); |
| 52 |
call.setTransport( new FileTransport() ); |
| 53 |
call.setUsername(opts.getUser() ); |
| 54 |
call.setPassword(opts.getPassword() ); |
| 55 |
call.setTimeout(new Integer(10000)); |
| 56 |
|
| 57 |
Float res = new Float(0.0F); |
| 58 |
res = (Float) call.invoke( new Object[] {symbol} ); |
| 59 |
|
| 60 |
System.out.println( symbol + ": " + res ); |
| 61 |
|
| 62 |
reader.halt(); |
| 63 |
} |
| 64 |
} |