butek 02/04/08 07:35:13
Modified: java/samples/jaxrpc GetQuote1.java
java/samples/stock GetInfo.java
java/test/functional TestJAXRPCSamples.java
Added: java/samples/jaxrpc GetInfo.java
Log:
More JAX-RPC compliant sample work:
- added GetInfo which mirrors stock/GetInfo
- fixed the original GetInfo so it works with the latest runtime
- tweaked samples/jaxrpc/GetQuote1 so that it fits better into the test harness.
Revision Changes Path
1.2 +27 -31 xml-axis/java/samples/jaxrpc/GetQuote1.java
Index: GetQuote1.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/jaxrpc/GetQuote1.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GetQuote1.java 5 Apr 2002 17:51:30 -0000 1.1
+++ GetQuote1.java 8 Apr 2002 14:35:09 -0000 1.2
@@ -196,7 +196,7 @@
/* Now use those QNames as pointers into the WSDL doc */
/******************************************************/
Service service = ServiceFactory.newInstance().createService(
- new URL("file:GetQuote.wsdl"), servQN);
+ new URL("file:samples/stock/GetQuote.wsdl"), servQN);
Call call = service.createCall(portQN, "getQuote");
/* Strange - but allows the user to change just certain portions of */
@@ -218,41 +218,37 @@
/* Reuse the Call object for a different call */
/**********************************************/
call.setOperationName(new QName("urn:xmltoday-delayed-quotes", "test"));
+ call.removeAllParameters();
call.setReturnType(XMLType.XSD_STRING);
System.out.println(call.invoke(new Object[]{}));
return ((Float) result).floatValue();
} // getQuote3
- public static void main(String args[]) {
- try {
- String save_args[] = new String[args.length];
- float val;
- GetQuote1 gq = new GetQuote1();
-
- /* Call the getQuote() that uses the WDSL */
- /******************************************/
- System.out.println("Using WSDL");
- System.arraycopy(args, 0, save_args, 0, args.length);
- val = gq.getQuote1(args);
- System.out.println(gq.symbol + ": " + val);
-
- /* Call the getQuote() that does it all manually */
- /*************************************************/
- System.out.println("Manually");
- System.arraycopy(save_args, 0, args, 0, args.length);
- val = gq.getQuote2(args);
- System.out.println(gq.symbol + ": " + val);
-
- /* Call the getQuote() that uses Axis's generated WSDL */
- /*******************************************************/
- System.out.println("WSDL + Reuse Call");
- System.arraycopy(save_args, 0, args, 0, args.length);
- val = gq.getQuote3(args);
- System.out.println(gq.symbol + ": " + val);
- }
- catch(Exception e) {
- e.printStackTrace();
- }
+ public static void main(String args[]) throws Exception {
+ String save_args[] = new String[args.length];
+ float val;
+ GetQuote1 gq = new GetQuote1();
+
+ /* Call the getQuote() that uses the WDSL */
+ /******************************************/
+ System.out.println("Using WSDL");
+ System.arraycopy(args, 0, save_args, 0, args.length);
+ val = gq.getQuote1(args);
+ System.out.println(gq.symbol + ": " + val);
+
+ /* Call the getQuote() that does it all manually */
+ /*************************************************/
+ System.out.println("Manually");
+ System.arraycopy(save_args, 0, args, 0, args.length);
+ val = gq.getQuote2(args);
+ System.out.println(gq.symbol + ": " + val);
+
+ /* Call the getQuote() that uses Axis's generated WSDL */
+ /*******************************************************/
+ System.out.println("WSDL + Reuse Call");
+ System.arraycopy(save_args, 0, args, 0, args.length);
+ val = gq.getQuote3(args);
+ System.out.println(gq.symbol + ": " + val);
} // main
}
1.1 xml-axis/java/samples/jaxrpc/GetInfo.java
Index: GetInfo.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package samples.jaxrpc;
import org.apache.axis.encoding.XMLType; // This should probably be
javax.xml.rpc.encoding.XMLType if we're told that class is approved (ie., it gets into
the spec rather than just in the RI).
import org.apache.axis.utils.Options;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.namespace.QName;
/**
* This version of GetInfo is a near-duplicate of the GetInfo class in
* samples/stock. This version is strictly JAX-RPC compliant. It uses
* no AXIS enhancements.
*
* @author Russell Butek ([EMAIL PROTECTED])
*/
public class GetInfo {
public static void main(String args[]) throws Exception {
Options opts = new Options(args);
args = opts.getRemainingArgs();
if (args == null || args.length % 2 != 0) {
System.err.println("Usage: GetInfo <symbol> <datatype>");
System.exit(1);
}
String symbol = args[0];
Service service = ServiceFactory.newInstance().createService(null);
Call call = service.createCall();
call.setTargetEndpointAddress(opts.getURL());
call.setOperationName(new QName("urn:cominfo", "getInfo"));
call.addParameter("symbol", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("info", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
call.setProperty(Call.USERNAME_PROPERTY, opts.getUser());
call.setProperty(Call.PASSWORD_PROPERTY, opts.getPassword());
String res = (String) call.invoke(new Object[] {args[0], args[1]});
System.out.println(symbol + ": " + res);
} // main
}
1.21 +1 -0 xml-axis/java/samples/stock/GetInfo.java
Index: GetInfo.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/GetInfo.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- GetInfo.java 27 Mar 2002 16:46:55 -0000 1.20
+++ GetInfo.java 8 Apr 2002 14:35:13 -0000 1.21
@@ -89,6 +89,7 @@
call.setOperationName( new QName("urn:cominfo", "getInfo") );
call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
call.addParameter( "info", XMLType.XSD_STRING, ParameterMode.IN );
+ call.setReturnType( XMLType.XSD_STRING );
call.setUsername( opts.getUser() );
call.setPassword( opts.getPassword() );
1.2 +36 -7 xml-axis/java/test/functional/TestJAXRPCSamples.java
Index: TestJAXRPCSamples.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/TestJAXRPCSamples.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestJAXRPCSamples.java 5 Apr 2002 17:51:30 -0000 1.1
+++ TestJAXRPCSamples.java 8 Apr 2002 14:35:13 -0000 1.2
@@ -56,10 +56,15 @@
package test.functional;
import junit.framework.TestCase;
+
import org.apache.axis.AxisFault;
+
import org.apache.axis.client.AdminClient;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import samples.jaxrpc.GetInfo;
import samples.jaxrpc.GetQuote1;
/**
@@ -85,7 +90,7 @@
} // doTestGetQuoteXXX
public void doTestGetQuoteMain() throws Exception {
- String[] args = {"-uuser1", "-wpass1", "IBM"};
+ String[] args = {"-uuser1", "-wpass1", "XXX"};
GetQuote1.main(args);
} // doTestGetQuoteMain
@@ -94,14 +99,9 @@
AdminClient.main(args);
} // doTestStockNoAction
- public static void main(String args[]) throws Exception {
- TestJAXRPCSamples tester = new TestJAXRPCSamples("tester");
- tester.testGetQuote();
- } // main
-
public void testGetQuote() throws Exception {
try {
- log.info("Testing JAX-RPC GetQuote sample.");
+ log.info("Testing JAX-RPC GetQuote1 sample.");
log.info("Testing deployment...");
doTestDeploy();
log.info("Testing service...");
@@ -117,6 +117,35 @@
throw new Exception("Fault returned from test: " + t);
}
} // testGetQuote
+
+ public void testGetInfo() throws Exception {
+ try {
+ log.info("Testing JAX-RPC GetInfo sample.");
+ log.info("Testing deployment...");
+ doTestDeploy();
+ log.info("Testing service...");
+ String[] args = {"IBM", "symbol"};
+ GetInfo.main(args);
+ args = new String[] {"ALLR", "name"};
+ GetInfo.main(args);
+ args = new String[] {"CSCO", "address"};
+ GetInfo.main(args);
+ log.info("Testing undeployment...");
+ doTestUndeploy();
+ log.info("Test complete.");
+ }
+ catch (Throwable t) {
+ if (t instanceof AxisFault) ((AxisFault)t).dump();
+ t.printStackTrace();
+ throw new Exception("Fault returned from test: " + t);
+ }
+ } // testGetInfo
+
+ public static void main(String args[]) throws Exception {
+ TestJAXRPCSamples tester = new TestJAXRPCSamples("tester");
+ tester.testGetQuote();
+ tester.testGetInfo();
+ } // main
}