You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ro...@apache.org on 2001/06/21 04:46:03 UTC
cvs commit: xml-axis/java/test/functional TestTCPTransportSample.java FunctionalTests.java TestStockSample.java TestTransportSample.java TestTCPEcho.java
robj 01/06/20 19:46:02
Modified: java build.xml
java/samples/addressbook deploy.xml
java/samples/bidbuy TestClient.java deploy.xml
java/samples/stock GetQuote.java StockQuoteService.jws
client_deploy.xml deploy.xml undeploy.xml
java/samples/transport FileReader.java FileSender.java
FileTest.java
java/src/org/apache/axis AxisEngine.java
java/src/org/apache/axis/client/http AdminClient.java
java/src/org/apache/axis/handlers JWSHandler.java
java/src/org/apache/axis/handlers/http
HTTPActionHandler.java
java/src/org/apache/axis/server AxisServer.java
java/src/org/apache/axis/transport/http HTTPSender.java
SimpleAxisServer.java
java/src/org/apache/axis/utils Admin.java
java/test build_functional_tests.xml
java/test/functional FunctionalTests.java
TestStockSample.java TestTransportSample.java
Added: java/samples/transport/tcp AdminClient.java TCPListener.java
TCPSender.java TCPTransport.java
java/src/org/apache/axis/client AdminClient.java
java/src/org/apache/axis/client/tcp README
java/src/org/apache/axis/handlers/tcp README
java/src/org/apache/axis/transport/tcp README
java/test/functional TestTCPTransportSample.java
Removed: java/src/org/apache/axis/client/tcp TCPTransport.java
java/src/org/apache/axis/handlers/tcp TCPActionHandler.java
java/src/org/apache/axis/transport/tcp AxisListener.java
PseudoStockQuoteService.java TCPSender.java
java/test/functional TestTCPEcho.java
Log:
Fixed up various SOAPAction and body dispatch issues:
- Added "all-tests" build target
- Made JWSHandler always set service if .jws URL
- Made HTTPActionHandler deal gracefully with SOAPAction: ""
- Patched Admin to look at local name
- Patched all deploy.xml, etc. to allow body dispatch for admin requests
- Copy .jws file to build/jws to allow functional test to actually build it
- Change jws test to verify JWS-specific return value
- Dike out IBM test
- Make TCP transport into a sample, using body dispatch
- Remove "SOAPAction hack" from file transport
- Add stock test for SOAPAction: "" over HTTP
Revision Changes Path
1.26 +4 -0 xml-axis/java/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/build.xml,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- build.xml 2001/06/18 19:33:17 1.25
+++ build.xml 2001/06/21 02:45:18 1.26
@@ -237,6 +237,10 @@
<ant antfile="test/build_functional_tests.xml" />
</target>
+ <!-- All tests -->
+ <target name="all-tests" depends="junit, functional-tests">
+ </target>
+
<!-- =================================================================== -->
<!-- Creates the API documentation -->
<!-- =================================================================== -->
1.2 +3 -2 xml-axis/java/samples/addressbook/deploy.xml
Index: deploy.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/addressbook/deploy.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- deploy.xml 2001/06/14 07:03:57 1.1
+++ deploy.xml 2001/06/21 02:45:21 1.2
@@ -7,7 +7,8 @@
<!-- after the axis server is running -->
<!-- This file will be replaced by WSDD once it's ready -->
-<deploy>
+<m:deploy xmlns:m="AdminService">
+
<chain name="book" flow="RPCDispatcher" />
<service name="urn:AddressFetcher2" pivot="book" >
@@ -41,4 +42,4 @@
</bean>
-->
-</deploy>
+</m:deploy>
1.4 +1 -1 xml-axis/java/samples/bidbuy/TestClient.java
Index: TestClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/bidbuy/TestClient.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestClient.java 2001/06/01 06:47:51 1.3
+++ TestClient.java 2001/06/21 02:45:23 1.4
@@ -147,7 +147,7 @@
// issue the request
String receipt = (String) call.invoke(
- "http://www.soapinterop.org/Bid", "Buy",
+ "http://www.soapinterop.org/Buy", "Buy",
new Object[] {new RPCParam("PO", po)} );
System.out.println(receipt);
1.6 +2 -2 xml-axis/java/samples/bidbuy/deploy.xml
Index: deploy.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/bidbuy/deploy.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- deploy.xml 2001/06/07 19:42:43 1.5
+++ deploy.xml 2001/06/21 02:45:23 1.6
@@ -7,7 +7,7 @@
<!-- after the axis server is running -->
<!-- This file will be replaced by WSDD once it's ready -->
-<deploy>
+<m:deploy xmlns:m="AdminService">
<chain name="bid" flow="RPCDispatcher" />
<service name="http://www.soapinterop.org/RequestForQuote" pivot="bid" >
@@ -64,4 +64,4 @@
<reg:Service classname="samples.bidbuy.Service"/>
</bean>
-</deploy>
+</m:deploy>
1.22 +10 -2 xml-axis/java/samples/stock/GetQuote.java
Index: GetQuote.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/GetQuote.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- GetQuote.java 2001/06/14 16:31:02 1.21
+++ GetQuote.java 2001/06/21 02:45:25 1.22
@@ -89,8 +89,16 @@
System.exit(1);
}
- String action = "urn:xmltoday-delayed-quotes";
+ String service = "urn:xmltoday-delayed-quotes";
+ String action = service;
symbol = args[0] ;
+
+ // TESTING HACK BY ROBJ
+ if (symbol.equals("XXX_noaction")) {
+ symbol = "XXX";
+ action = "";
+ }
+
ServiceClient call = new ServiceClient
(new HTTPTransport(opts.getURL(), action));
ServiceDescription sd = new ServiceDescription("stockQuotes", true);
@@ -116,7 +124,7 @@
// the namespace of the call should be the service.
// ...according to Glen... -- RobJ
Object ret = call.invoke(
- action, "getQuote", new Object[] {symbol} );
+ service, "getQuote", new Object[] {symbol} );
if (ret instanceof String) {
System.out.println("Received problem response from server: "+ret);
throw new AxisFault("", (String)ret, null, null);
1.4 +15 -13 xml-axis/java/samples/stock/StockQuoteService.jws
Index: StockQuoteService.jws
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/StockQuoteService.jws,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StockQuoteService.jws 2001/03/03 01:07:04 1.3
+++ StockQuoteService.jws 2001/06/21 02:45:26 1.4
@@ -57,9 +57,11 @@
import java.util.* ;
import java.net.URL;
-import org.jdom.* ;
-import org.jdom.input.SAXBuilder ;
+import org.w3c.dom.* ;
+import org.apache.axis.utils.XMLUtils ;
+import org.apache.axis.utils.Debug;
+
/**
* See \samples\stock\readme for info.
*
@@ -72,21 +74,21 @@
// http://www.xmltoday.com/examples/stockquote/. The IP addr
// below came from the host that the above form posts to ..
- if ( symbol.equals("XXX") ) return( (float) 55.25 );
+ // NOTE THAT THIS RETURNS 66.25 WHERE THE ORDINARY EXAMPLE RETURNS 55.25!
+ if ( symbol.equals("XXX") ) return( (float) 66.25 );
- URL url = new URL( "http://www.xmltoday.com/examples/" +
+ Document doc = null ;
+
+ doc = XMLUtils.newDocument( "http://www.xmltoday.com/examples/" +
"stockquote/getxmlquote.vep?s="+symbol );
-
- SAXBuilder parser = new SAXBuilder();
-
- Document doc = parser.build( url );
- Element elem = doc.getRootElement();
- elem = elem.getChild( "stock_quote" );
- List list = elem.getChildren( "price" );
+ Element elem = doc.getDocumentElement();
+ NodeList list = elem.getElementsByTagName("stock_quote");
- elem = (Element) list.get( 0 );
- String quoteStr = elem.getAttributeValue("value");
+ elem = (Element) list.item(0);
+ list = elem.getElementsByTagName( "price" );
+ elem = (Element) list.item( 0 );
+ String quoteStr = elem.getAttribute("value");
try {
return Float.valueOf(quoteStr).floatValue();
} catch (NumberFormatException e1) {
1.4 +2 -2 xml-axis/java/samples/stock/client_deploy.xml
Index: client_deploy.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/client_deploy.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- client_deploy.xml 2001/04/22 19:29:12 1.3
+++ client_deploy.xml 2001/06/21 02:45:26 1.4
@@ -4,8 +4,8 @@
<!-- from the same dir that the Axis client will run in -->
<!-- This file will be replaced by WSDD once it's ready -->
-<deploy>
+<m:deploy xmlns:m="AdminService">
<handler name="log" class="org.apache.axis.handlers.LogHandler" />
<service name="urn:xmltoday-delayed-quotes" input="log" output="log" />
-</deploy>
+</m:deploy>
1.9 +2 -2 xml-axis/java/samples/stock/deploy.xml
Index: deploy.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/deploy.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- deploy.xml 2001/05/31 09:22:55 1.8
+++ deploy.xml 2001/06/21 02:45:26 1.9
@@ -7,7 +7,7 @@
<!-- after the axis server is running -->
<!-- This file will be replaced by WSDD once it's ready -->
-<deploy>
+<m:deploy xmlns:m="AdminService">
<handler name="authen" class="org.apache.axis.handlers.SimpleAuthenticationHandler" />
<handler name="author" class="org.apache.axis.handlers.SimpleAuthorizationHandler" />
<chain name="checks" flow="authen,author" />
@@ -21,4 +21,4 @@
<option name="className" value="samples.stock.ComInfoService" />
<option name="methodName" value="getInfo" />
</service>
-</deploy>
+</m:deploy>
1.3 +2 -2 xml-axis/java/samples/stock/undeploy.xml
Index: undeploy.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/undeploy.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- undeploy.xml 2001/03/21 01:17:02 1.2
+++ undeploy.xml 2001/06/21 02:45:27 1.3
@@ -7,11 +7,11 @@
<!-- after the axis server is running -->
<!-- This file will be replaced by WSDD once it's ready -->
-<undeploy>
+<m:undeploy xmlns:m="AdminService">
<handler name="authen" />
<handler name="author" />
<chain name="checks" />
<chain name="rpc" />
<service name="urn:xmltoday-delayed-quotes" handler="rpc" />
<service name="urn:cominfo" handler="rpc" />
-</undeploy>
+</m:undeploy>
1.12 +1 -8 xml-axis/java/samples/transport/FileReader.java
Index: FileReader.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/FileReader.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- FileReader.java 2001/06/18 19:33:21 1.11
+++ FileReader.java 2001/06/21 02:45:30 1.12
@@ -96,13 +96,6 @@
MessageContext msgContext = new MessageContext(server);
msgContext.setRequestMessage( msg );
- // SOAPAction hack
- byte[] buf = new byte[50];
- fis.read( buf, 0, 50 );
- String action = new String( buf );
- msgContext.setTargetService( action.trim() );
- // end of hack
-
try {
server.invoke( msgContext );
msg = msgContext.getResponseMessage();
@@ -114,7 +107,7 @@
msg.setMessageContext(msgContext);
}
- buf = (byte[]) msg.getAsBytes();
+ byte[] buf = (byte[]) msg.getAsBytes();
FileOutputStream fos = new FileOutputStream( "xml" + thisNum + ".res" );
fos.write( buf );
fos.close();
1.3 +4 -11 xml-axis/java/samples/transport/FileSender.java
Index: FileSender.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/FileSender.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileSender.java 2001/06/12 15:42:57 1.2
+++ FileSender.java 2001/06/21 02:45:31 1.3
@@ -4,7 +4,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -12,7 +12,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -20,7 +20,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * 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,
@@ -28,7 +28,7 @@
*
* 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
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -82,13 +82,6 @@
byte[] buf = (byte[]) msg.getAsBytes();
try {
FileOutputStream fos = new FileOutputStream( "xml" + nextNum + ".req" );
-
- // Remove this SOAPAction hack once we support not having it
- String tmp = msgContext.getTargetService();
- tmp += " ";
- tmp = tmp.substring( 0, 50 );
- fos.write( tmp.getBytes() );
- // end of hack
fos.write( buf );
fos.close();
1.6 +1 -3 xml-axis/java/samples/transport/FileTest.java
Index: FileTest.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/FileTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FileTest.java 2001/06/15 23:42:58 1.5
+++ FileTest.java 2001/06/21 02:45:31 1.6
@@ -6,7 +6,6 @@
import org.apache.axis.client.AxisClient ;
import org.apache.axis.client.ServiceClient ;
import org.apache.axis.client.Transport ;
-import org.apache.axis.client.http.HTTPTransport ;
import org.apache.axis.utils.Debug ;
import org.apache.axis.utils.Options ;
import org.apache.axis.encoding.* ;
@@ -36,8 +35,7 @@
}
String symbol = args[0] ;
- ServiceClient call = new ServiceClient
- (new HTTPTransport(opts.getURL(), "urn:xmltoday-delayed-quotes"));
+ ServiceClient call = new ServiceClient();
ServiceDescription sd = new ServiceDescription("stockQuotes", true);
sd.addOutputParam("return", SOAPTypeMappingRegistry.XSD_FLOAT);
call.setServiceDescription(sd);
1.1 xml-axis/java/samples/transport/tcp/AdminClient.java
Index: AdminClient.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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.transport.tcp ;
import org.apache.axis.utils.Options ;
import org.apache.axis.client.ServiceClient;
import org.apache.axis.transport.http.HTTPConstants;
import java.net.URL;
/**
* An admin client object, specific to HTTP.
*
* @author Rob Jellinghaus (robj@unrealities.com)
* @author Doug Davis (dug@us.ibm.com)
*/
public class AdminClient extends org.apache.axis.client.AdminClient {
public static void main(String args[]) {
try {
new samples.transport.tcp.AdminClient().doAdmin(args);
}
catch( Exception e ) {
System.err.println( e );
e.printStackTrace( System.err );
}
}
/**
* create an appropriate ServiceClient
*/
public ServiceClient getServiceClient (Options opts, String[] args) throws Exception {
URL url = new URL(opts.getURL());
ServiceClient client = new ServiceClient
( new TCPTransport(url.getHost(), ""+url.getPort()) );
return client;
}
}
1.1 xml-axis/java/samples/transport/tcp/TCPListener.java
Index: TCPListener.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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.transport.tcp;
import java.io.*;
import java.util.*;
import org.apache.axis.* ;
import org.apache.axis.server.* ;
import org.apache.axis.utils.* ;
import org.apache.axis.registries.HandlerRegistry;
import org.apache.axis.transport.http.NonBlockingBufferedInputStream;
import org.apache.axis.handlers.soap.SOAPService;
import java.net.*;
/**
* Listen for incoming socket connections on the specified socket. Take
* incoming messages and dispatch them.
*
* @author Rob Jellinghaus (robj@unrealities.com)
* @author Doug Davis (dug@us.ibm.com)
*/
public class TCPListener implements Runnable {
// These have default values.
private String transportReqName = "TCP.request";
private String transportRespName = "TCP.response";
private static final String AXIS_ENGINE = "AxisEngine" ;
private int port;
private ServerSocket srvSocket;
private AxisEngine engine = null ;
// becomes true when we want to quit
private boolean done = false;
public static void main (String args[]) {
new TCPListener(args).run();
}
public TCPListener (String[] args) {
// look for -p, -d arguments
try {
Options options = new Options(args);
port = new URL(options.getURL()).getPort();
String tmp;
if ((tmp = options.isValueSet('d')) != null) {
Debug.setDebugLevel(Integer.parseInt(tmp));
}
} catch (MalformedURLException ex) {
System.err.println("Hosed URL: "+ex);
System.exit(1);
}
try {
srvSocket = new ServerSocket(port);
} catch (IOException ex) {
System.err.println("Can't create server socket on port "+port);
System.exit(1);
}
System.out.println("AxisListener is listening on port "+port+".");
}
public void run () {
if (srvSocket == null) {
return;
}
Socket sock;
while (!done) {
try {
sock = srvSocket.accept();
new Thread(new SocketHandler(sock)).start();
} catch (IOException ex) {
/** stop complaining about this! it seems to happen on quit,
and is not worth mentioning. unless I am confused. -- RobJ
System.err.println("Got IOException on srvSocket.accept: "+ex);
ex.printStackTrace();
*/
}
}
}
public class SocketHandler implements Runnable {
private Socket socket;
public SocketHandler (Socket socket) {
this.socket = socket;
}
public void run () {
// get the input stream
if ( engine == null ) {
engine = new AxisServer();
engine.init();
engine.addTransportForProtocol("tcp", new TCPTransport());
HandlerRegistry hr = engine.getHandlerRegistry();
HandlerRegistry sr = engine.getServiceRegistry();
// add the TCPSender
hr.add("TCPSender", new TCPSender());
SimpleChain c = new SimpleChain();
hr.add( transportReqName, c );
}
/* Place the Request message in the MessagContext object - notice */
/* that we just leave it as a 'ServletRequest' object and let the */
/* Message processing routine convert it - we don't do it since we */
/* don't know how it's going to be used - perhaps it might not */
/* even need to be parsed. */
/*******************************************************************/
MessageContext msgContext = new MessageContext(engine);
InputStream inp;
try {
inp = socket.getInputStream();
} catch (IOException ex) {
System.err.println("Couldn't get input stream from "+socket);
return;
}
// ROBJ 911
// the plain ol' inputstream seems to hang in the SAX parse..... WHY?????
// because there is no content length!
//Message msg = new Message( nbbinp, "InputStream" );
Message msg = null;
try {
StringBuffer line = new StringBuffer();
int b = 0;
while ((b = inp.read()) != '\r') {
line.append((char)b);
}
// got to '\r', skip it and '\n'
if (inp.read() != '\n') {
System.err.println("Length line "+line+" was not terminated with \r\n");
return;
}
// TEST SUPPORT ONLY
// If the line says "ping", then respond "\n".
// If the line says "quit", then respond "\n" and exit.
if (line.toString().equals("ping")) {
socket.getOutputStream().write(new String("\n").getBytes());
return;
} else if (line.toString().equals("quit")) {
// peacefully die
socket.getOutputStream().write(new String("\n").getBytes());
socket.close();
// The following appears to deadlock. It will get cleaned
// up on exit anyway...
// srvSocket.close();
System.err.println("AxisListener quitting.");
System.exit(0);
}
// OK, assume it is content length
int len = Integer.parseInt(line.toString());
// read that many bytes into ByteArrayInputStream...
// experiment, doesn't work:
// NonBlockingBufferedInputStream nbbinp = new NonBlockingBufferedInputStream();
// nbbinp.setContentLength(len);
// nbbinp.setInputStream(inp);
// msg = new Message(nbbinp, "InputStream");
byte[] mBytes = new byte[len];
inp.read(mBytes);
msg = new Message(new ByteArrayInputStream(mBytes));
} catch (IOException ex) {
System.err.println("Couldn't read from socket input stream: "+ex);
return;
}
/* Set the request(incoming) message field in the context */
/**********************************************************/
msgContext.setRequestMessage( msg );
/* Set the Transport Specific Request/Response chains IDs */
/******************************************************/
msgContext.setProperty(MessageContext.TRANS_REQUEST , transportReqName );
msgContext.setProperty(MessageContext.TRANS_RESPONSE, transportRespName );
try {
/* Invoke the Axis engine... */
/*****************************/
engine.invoke( msgContext );
}
catch( Exception e ) {
if ( !(e instanceof AxisFault) )
e = new AxisFault( e );
msgContext.setResponseMessage( new Message((AxisFault)e) );
}
/* Send it back along the wire... */
/***********************************/
msg = msgContext.getResponseMessage();
String response = (String) msg.getAsString();
if (msg == null) response="No data";
try {
OutputStream buf = new BufferedOutputStream(socket.getOutputStream());
// this should probably specify UTF-8, but for now, for Java interop,
// use default encoding
buf.write(response.getBytes());
buf.close();
} catch (IOException ex) {
System.err.println("Can't write response to socket "+port+", response is: "+response);
}
}
}
}
1.1 xml-axis/java/samples/transport/tcp/TCPSender.java
Index: TCPSender.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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.transport.tcp;
import java.io.* ;
import java.net.* ;
import java.util.* ;
import java.lang.reflect.*;
import org.apache.axis.* ;
import org.apache.axis.utils.* ;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPHeader;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.transport.http.NonBlockingBufferedInputStream;
import org.apache.axis.encoding.Base64 ;
import org.w3c.dom.* ;
/**
* This is meant to be used on a SOAP Client to call a SOAP server.
*
* @author Rob Jellinghaus (robj@unrealities.com)
* @author Doug Davis (dug@us.ibm.com)
*/
public class TCPSender extends BasicHandler {
public void invoke(MessageContext msgContext) throws AxisFault {
Debug.Print( 1, "Enter: TCPSender::invoke" );
/* Find the service we're invoking so we can grab it's options */
/***************************************************************/
String targetURL = null ;
Message outMsg = null ;
String reqEnv = null ;
targetURL = msgContext.getStrProp( MessageContext.TRANS_URL);
try {
// This is a totally random, temporary URL specification:
// http://host:port/service-name ??????? hmmmmmm
URL tmpURL = new URL( targetURL );
String host = tmpURL.getHost();
int port = tmpURL.getPort();
byte[] buf = new byte[4097];
int rc = 0 ;
Socket sock = null ;
/* comment out SSL stuff for now
if (tmpURL.getProtocol().equalsIgnoreCase("https")) {
if ( (port = tmpURL.getPort()) == -1 ) port = 443;
String tunnelHost = System.getProperty("https.proxyHost");
String tunnelPortString = System.getProperty("https.proxyPort");
String tunnelUsername = System.getProperty("https.proxyUsername");
String tunnelPassword = System.getProperty("https.proxyPassword");
try {
Class SSLSocketFactoryClass =
Class.forName("javax.net.ssl.SSLSocketFactory");
Class SSLSocketClass = Class.forName("javax.net.ssl.SSLSocket");
Method createSocketMethod =
SSLSocketFactoryClass.getMethod("createSocket",
new Class[] {String.class, Integer.TYPE});
Method getDefaultMethod =
SSLSocketFactoryClass.getMethod("getDefault", new Class[] {});
Method startHandshakeMethod =
SSLSocketClass.getMethod("startHandshake", new Class[] {});
Object factory = getDefaultMethod.invoke(null, new Object[] {});
Object sslSocket = null;
if (tunnelHost == null || tunnelHost.equals("")) {
// direct SSL connection
sslSocket = createSocketMethod .invoke(factory,
new Object[] {host, new Integer(port)});
} else {
// SSL tunnelling through proxy server
Method createSocketMethod2 =
SSLSocketFactoryClass.getMethod("createSocket",
new Class[] {Socket.class, String.class, Integer.TYPE, Boolean.TYPE});
int tunnelPort = (tunnelPortString != null? (Integer.parseInt(tunnelPortString) < 0? 443: Integer.parseInt(tunnelPortString)): 443);
Object tunnel = createSocketMethod .invoke(factory,
new Object[] {tunnelHost, new Integer(tunnelPort)});
// The tunnel handshake method (condensed and made reflexive)
OutputStream tunnelOutputStream = (OutputStream)SSLSocketClass.getMethod("getOutputStream", new Class[] {}).invoke(tunnel, new Object[] {});
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(tunnelOutputStream)));
out.print("CONNECT " + host + ":" + port + " HTTP/1.0\n\r\n\r");
out.flush();
InputStream tunnelInputStream = (InputStream)SSLSocketClass.getMethod("getInputStream", new Class[] {}).invoke(tunnel, new Object[] {});
//BufferedReader in = new BufferedReader(new InputStreamReader(tunnelInputStream));
//DataInputStream in = new DataInputStream(tunnelInputStream);
Debug.Print(1, "Is tunnelInputStream null? " + String.valueOf(tunnelInputStream == null));
String replyStr = ""; int i;
while ((i = tunnelInputStream.read()) != '\n' && i != '\r' && i != -1) { replyStr += String.valueOf((char)i); Debug.Print(1, "got a character in reply, so far: " + replyStr); }
if (!replyStr.startsWith("HTTP/1.0 200") && !replyStr.startsWith("HTTP/1.1 200")) {
throw new IOException("Unable to tunnel through " + tunnelHost + ":" + tunnelPort + ". Proxy returns \"" + replyStr + "\"");
}
// End of condensed reflective tunnel handshake method
sslSocket = createSocketMethod2.invoke(factory,
new Object[] {tunnel, host, new Integer(port), new Boolean(true)});
Debug.Print( 1, "Set up SSL tunnelling through " + tunnelHost + ":" +tunnelPort);
}
// must shake out hidden errors!
startHandshakeMethod.invoke(sslSocket, new Object[] {});
sock = (Socket)sslSocket;
} catch (ClassNotFoundException cnfe) {
Debug.Print( 1, "SSL feature disallowed: JSSE files not installed or present in classpath");
throw new AxisFault(cnfe);
} catch (NumberFormatException nfe) {
Debug.Print( 1, "Proxy port number, \"" + tunnelPortString + "\", incorrectly formatted");
throw new AxisFault(nfe);
}
Debug.Print( 1, "Created an SSL connection");
} else {
*/
sock = new Socket( host, port );
Debug.Print( 1, "Created an insecure HTTP connection");
/*
}
*/
reqEnv = (String) msgContext.getRequestMessage().getAsString();
//System.out.println("Msg: " + reqEnv);
BufferedInputStream inp = new BufferedInputStream(sock.getInputStream());
OutputStream out = sock.getOutputStream();
/*
StringBuffer otherHeaders = new StringBuffer();
String userID = null ;
String passwd = null ;
userID = msgContext.getStrProp( MessageContext.USERID );
passwd = msgContext.getStrProp( MessageContext.PASSWORD );
if ( userID != null ) {
StringBuffer tmpBuf = new StringBuffer();
tmpBuf.append( userID )
.append( ":" )
.append( (passwd == null) ? "" : passwd) ;
otherHeaders.append( HTTPConstants.HEADER_AUTHORIZATION )
.append( ": Basic " )
.append( Base64.encode( tmpBuf.toString().getBytes() ) )
.append("\n" );
}
StringBuffer header = new StringBuffer();
header.append( HTTPConstants.HEADER_POST )
.append(" " )
.append( ((tmpURL.getFile() == null ||
tmpURL.getFile().equals(""))? "/": tmpURL.getFile()) )
.append( " HTTP/1.0\r\n" )
.append( HTTPConstants.HEADER_CONTENT_LENGTH )
.append( ": " )
.append(reqEnv.length() )
.append( "\r\n" )
.append( HTTPConstants.HEADER_CONTENT_TYPE )
.append( ": text/xml\r\n" )
.append( (otherHeaders == null ? "" : otherHeaders.toString()) )
.append( HTTPConstants.HEADER_SOAP_ACTION )
.append( ": \"" )
.append( action )
.append( "\"\r\n\r\n" );
out.write( header.toString().getBytes() );
*/
byte[] bytes = reqEnv.getBytes();
String length = "" + bytes.length + "\r\n";
out.write(length.getBytes());
out.write( bytes );
out.flush();
Debug.Print( 1, "XML sent:" );
Debug.Print( 1, "---------------------------------------------------");
Debug.Print( 1, reqEnv );
/*
byte lastB=0, b ;
int len = 0 ;
int colonIndex = -1 ;
Hashtable headers = new Hashtable();
String name, value ;
// Need to add logic for getting the version # and the return code
// but that's for tomorrow!
for ( ;; ) {
if ( (b = (byte) inp.read()) == -1 ) break ;
if ( b != '\r' && b != '\n' ) {
if ( b == ':' ) colonIndex = len ;
lastB = (buf[len++] = b);
}
else if ( b == '\r' )
continue ;
else {
if ( len == 0 ) break ;
if ( colonIndex != -1 ) {
name = new String( buf, 0, colonIndex );
value = new String( buf, colonIndex+1, len-1-colonIndex );
}
else {
name = new String( buf, 0, len );
value = "" ;
}
Debug.Print( 1, name + value );
if ( msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE)==null){
// Reader status code
int start = name.indexOf( ' ' ) + 1 ;
String tmp = name.substring(start).trim();
int end = tmp.indexOf( ' ' );
if ( end != -1 ) tmp = tmp.substring( 0, end );
rc = Integer.parseInt( tmp );
msgContext.setProperty( HTTPConstants.MC_HTTP_STATUS_CODE,
new Integer(rc) );
msgContext.setProperty( HTTPConstants.MC_HTTP_STATUS_MESSAGE,
name.substring(end+1));
}
else
headers.put( name.toLowerCase(), value );
len = 0 ;
}
}
*/
if ( Debug.getDebugLevel() > 8 ) {
// Special case - if the debug level is this high then something
// really bad must be going on - so just dump the input stream
// to stdout.
byte b;
while ( (b = (byte) inp.read()) != -1 )
System.err.print((char)b);
System.err.println("");
}
outMsg = new Message( inp );
if (Debug.getDebugLevel() > 0) {
Debug.Print( 1, "\nNo Content-Length" );
Debug.Print( 1, "\nXML received:" );
Debug.Print( 1, "-----------------------------------------------");
Debug.Print( 1, (String) outMsg.getAsString() );
}
msgContext.setResponseMessage( outMsg );
}
catch( Exception e ) {
Debug.Print( 1, e );
e.printStackTrace();
if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
throw (AxisFault) e ;
}
Debug.Print( 1, "Exit: TCPSender::invoke" );
}
public void undo(MessageContext msgContext) {
Debug.Print( 1, "Enter: TCPSender::undo" );
Debug.Print( 1, "Exit: TCPSender::undo" );
}
};
1.1 xml-axis/java/samples/transport/tcp/TCPTransport.java
Index: TCPTransport.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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.transport.tcp;
import java.util.* ;
import org.apache.axis.* ;
import org.apache.axis.utils.Debug ;
import org.apache.axis.handlers.* ;
import org.apache.axis.registries.* ;
import org.apache.axis.client.Transport;
import org.apache.axis.client.AxisClient;
import org.apache.axis.client.ServiceClient;
// UGLY!!!!! -- see below in setupMessageContext -- RobJ
import org.apache.axis.client.Transport;
import org.apache.axis.client.http.HTTPTransport;
/**
* Extends Client by implementing the setupMessageContext function to
* set TCP-specific message context fields. May not even be necessary
* if we arrange things differently somehow.
*
* @author Rob Jellinghaus (robj@unrealities.com)
* @author Doug Davis (dug@us.ibm.com)
* @author Glen Daniels (gdaniels@allaire.com)
*/
public class TCPTransport extends Transport
{
private Handler engine;
static private boolean initedClient = false;
private String host;
private String port;
public TCPTransport () {
}
public TCPTransport (String host, String port) {
this.host = host;
this.port = port;
}
/**
* Find/load the registries and save them so we don't need to do this
* each time we're called.
*/
public void init(AxisEngine engine) {
this.engine = engine;
// Load the simple handler registry and init it
Debug.Print( 1, "Enter: TCPTransport::init" );
// add the TCPSender
HandlerRegistry hr = engine.getHandlerRegistry();
hr.add("TCPSender", new TCPSender());
SimpleChain c = new SimpleChain();
hr.add( "TCP.request", c );
}
/**
* TCP properties
*/
static public String HOST = "tcp.host";
static public String PORT = "tcp.port";
/**
* Initialize the given MessageContext with the correct handlers and registries.
*/
public void initMessageContext (MessageContext mc, ServiceClient serv, AxisEngine engine)
{
HandlerRegistry sr = engine.getServiceRegistry();
if ( sr == null || sr.find("TCP.request") == null )
mc.setProperty( MessageContext.TRANS_REQUEST, "TCPSender" );
else
mc.setProperty( MessageContext.TRANS_REQUEST, "TCP.request" );
mc.setProperty(MessageContext.TRANS_RESPONSE, "TCP.response" );
}
/**
* Set up any transport-specific derived properties in the message context.
* @param context the context to set up
* @param message the client service instance
* @param engine the engine containing the registries
*/
public void setupMessageContext (MessageContext mc, ServiceClient serv, AxisEngine engine)
{
// kind of ugly... fake up a "http://host:port/" url to send down the chain
// ROBJ TODO: clean this up so we use TCP transport properties all the way down
// use serviceclient properties if any, otherwise use ours
if (host != null) serv.set(HOST, host);
if (port != null) serv.set(PORT, port);
String url = "http://"+serv.get(HOST)+":"+serv.get(PORT);
serv.set(HTTPTransport.URL, url);
}
}
1.11 +9 -6 xml-axis/java/src/org/apache/axis/AxisEngine.java
Index: AxisEngine.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisEngine.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AxisEngine.java 2001/06/18 18:34:21 1.10
+++ AxisEngine.java 2001/06/21 02:45:36 1.11
@@ -71,7 +71,6 @@
/** Temporary - this will be replaced by deployment
*/
import org.apache.axis.client.http.HTTPTransport;
-import org.apache.axis.client.tcp.TCPTransport;
/**
* An <code>AxisEngine</code> is the base class for AxisClient and
@@ -125,13 +124,12 @@
}
/** Load default transports
- *
+ *
* (these will be shared - really should be a factory, but
* we need to go over the architecture / patterns here
* anyway, so this is a quick P.O.C. for now)
*/
protocolSenders.put("http", new HTTPTransport());
- protocolSenders.put("tcp", new TCPTransport());
// Once we've got a LocalTransport class...
//
@@ -242,12 +240,17 @@
return transport;
}
+ public void addTransportForProtocol(String protocol, Transport transport)
+ {
+ protocolSenders.put(protocol, transport);
+ }
+
/*********************************************************************
* Administration and management APIs
- *
+ *
* These can get called by various admin adapters, such as JMX MBeans,
* our own Admin client, web applications, etc...
- *
+ *
*********************************************************************
*/
@@ -304,7 +307,7 @@
public void undeployService(String key)
{
getHandlerRegistry().remove(key);
- }
+ }
/**
* accessor only, for application session
1.20 +88 -58 xml-axis/java/src/org/apache/axis/client/AdminClient.java
1.5 +13 -80 xml-axis/java/src/org/apache/axis/client/http/AdminClient.java
Index: AdminClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/http/AdminClient.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AdminClient.java 2001/06/15 00:01:07 1.4
+++ AdminClient.java 2001/06/21 02:45:39 1.5
@@ -55,20 +55,8 @@
package org.apache.axis.client.http ;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-
import org.apache.axis.utils.Options ;
-import org.apache.axis.encoding.SerializationContext ;
-import org.apache.axis.message.SOAPEnvelope ;
-import org.apache.axis.message.SOAPBodyElement ;
import org.apache.axis.client.ServiceClient;
-import org.apache.axis.client.Transport;
-import org.apache.axis.Message ;
-import org.apache.axis.MessageContext ;
-import org.apache.axis.utils.Debug ;
-import org.apache.axis.encoding.ServiceDescription;
import org.apache.axis.transport.http.HTTPConstants;
/**
@@ -77,84 +65,29 @@
* @author Rob Jellinghaus (robj@unrealities.com)
* @author Doug Davis (dug@us.ibm.com)
*/
-
-public class AdminClient {
- // Temporary home until we find something better.
- static {
- // System.out.println("Registering URL stream handler factory.");
- URL.setURLStreamHandlerFactory(Transport.getURLStreamHandlerFactory());
- }
+public class AdminClient extends org.apache.axis.client.AdminClient {
public static void main(String args[]) {
try {
- new AdminClient().doAdmin(args);
+ new org.apache.axis.client.http.AdminClient().doAdmin(args);
}
catch( Exception e ) {
System.err.println( e );
e.printStackTrace( System.err );
}
}
-
- // do the real work, and throw exception if fubar
- // this is reused by the TestHTTPDeploy functional tests
- public void doAdmin (String[] args)
- throws Exception
- {
- Options opts = new Options( args );
-
- Debug.setDebugLevel( opts.isFlagSet('d') );
-
- args = opts.getRemainingArgs();
-
- if ( args == null ) {
- System.err.println( "Usage: AdminClient xml-files | list" );
- System.exit(1);
- }
-
- for ( int i = 0 ; i < args.length ; i++ ) {
- InputStream input = null ;
-
- if ( args[i].equals("list") ) {
- System.out.println( "Doing a list" );
- String str = "<list/>" ;
- input = new ByteArrayInputStream( str.getBytes() );
- } else if (args[i].equals("quit")) {
- System.out.println("Doing a quit");
- String str = "<quit/>";
- input = new ByteArrayInputStream(str.getBytes());
- }
- else {
- System.out.println( "Processing file: " + args[i] );
- input = new FileInputStream( args[i] );
- }
-
- ServiceClient client =
- new ServiceClient(opts.getURL());
-
- /** Set the action in case it's HTTP
- */
- client.set(HTTPConstants.MC_HTTP_SOAPACTION, "AdminService");
-
- Message inMsg = new Message( input, true );
- client.setRequestMessage( inMsg );
-
- if ( opts.isFlagSet('t') > 0 ) client.doLocal = true ;
- client.set( Transport.USER, opts.getUser() );
- client.set( Transport.PASSWORD, opts.getPassword() );
-
- client.invoke();
-
- Message outMsg = client.getMessageContext().getResponseMessage();
- client.getMessageContext().setServiceDescription(new ServiceDescription("Admin", false));
- input.close();
- SOAPEnvelope envelope = (SOAPEnvelope) outMsg.getAsSOAPEnvelope();
- SOAPBodyElement body = envelope.getFirstBody();
- StringWriter writer = new StringWriter();
- SerializationContext ctx = new SerializationContext(writer, client.getMessageContext());
- body.output(ctx);
- System.out.println(writer.toString());
- }
+
+ /**
+ * create an appropriate ServiceClient
+ */
+ public ServiceClient getServiceClient (Options opts, String[] args) throws Exception {
+ ServiceClient client = new ServiceClient(opts.getURL());
+ /** Set the action
+ */
+ client.set(HTTPConstants.MC_HTTP_SOAPACTION, "AdminService");
+ return client;
}
+
}
1.1 xml-axis/java/src/org/apache/axis/client/tcp/README
Index: README
===================================================================
This directory is dead!
THIS IS AN EX-DIRECTORY!
1.2 +11 -13 xml-axis/java/src/org/apache/axis/handlers/JWSHandler.java
Index: JWSHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JWSHandler.java 2001/06/13 15:39:09 1.1
+++ JWSHandler.java 2001/06/21 02:45:43 1.2
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -17,7 +17,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * 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,
@@ -25,7 +25,7 @@
*
* 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
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -62,7 +62,7 @@
/** A <code>JWSHandler</code> sets the target service and JWS filename
* in the context depending on the JWS configuration and the target URL.
- *
+ *
* @author Glen Daniels (gdaniels@allaire.com)
* @author Doug Davis (dug@us.ibm.com)
* @author Sam Ruby (rubys@us.ibm.com)
@@ -72,20 +72,18 @@
public void invoke(MessageContext msgContext) throws AxisFault
{
Debug.Print( 1, "Enter: JWSHandler::invoke" );
+
+ // FORCE the targetService to be JWS if the URL is right.
+ String realpath = msgContext.getStrProp(Constants.MC_REALPATH);
- // If there's already a targetService just return.
- if (msgContext.getServiceHandler() == null) {
- String realpath = msgContext.getStrProp(Constants.MC_REALPATH);
-
- if ((realpath!=null) && (realpath.endsWith(".jws"))) {
- msgContext.setTargetService(Constants.JWSPROCESSOR_TARGET) ;
- }
+ if ((realpath!=null) && (realpath.endsWith(".jws"))) {
+ msgContext.setTargetService(Constants.JWSPROCESSOR_TARGET) ;
}
Debug.Print( 1, "Exit : JWSHandler::invoke" );
}
- public void undo(MessageContext msgContext)
+ public void undo(MessageContext msgContext)
{
Debug.Print( 1, "Enter: JWSHandler::undo" );
Debug.Print( 1, "Exit: JWSHandler::undo" );
1.4 +24 -14 xml-axis/java/src/org/apache/axis/handlers/http/HTTPActionHandler.java
Index: HTTPActionHandler.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/http/HTTPActionHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HTTPActionHandler.java 2001/06/13 11:37:22 1.3
+++ HTTPActionHandler.java 2001/06/21 02:45:45 1.4
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -17,7 +17,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * 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,
@@ -25,7 +25,7 @@
*
* 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
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -66,10 +66,10 @@
* property from the HTTPAction property. We expect there to be a
* Router on the chain after us, to dispatch to the service named in
* the SOAPAction.
- *
+ *
* In the real world, this might do some more complex mapping of
* SOAPAction to a TargetService.
- *
+ *
* @author Glen Daniels (gdaniels@allaire.com)
* @author Doug Davis (dug@us.ibm.com)
*/
@@ -90,24 +90,34 @@
* service does a mapping between SOAPAction and target. Therefore
* if we get here with no action, we're in trouble.
*/
- if (action == null)
- throw new AxisFault( "Server.NoHTTPAction",
- "No HTTPAction property in context",
+ if (action == null) {
+ throw new AxisFault( "Server.NoHTTPSOAPAction",
+ "No HTTP SOAPAction property in context",
null, null );
+ }
action = action.trim();
-
- if (action.charAt(0) == '\"') {
+
+ // handle empty SOAPAction
+ if (action.length() > 0 && action.charAt(0) == '\"') {
// assert(action.endsWith("\"")
- action = action.substring(1, action.length() - 1);
+ if (action.equals("\"\"")) {
+ action = "";
+ } else {
+ action = action.substring(1, action.length() - 1);
+ }
+ }
+
+ // if action is zero-length string, don't set anything
+ if (action.length() > 0) {
+ msgContext.setTargetService( action );
}
- msgContext.setTargetService( action );
}
Debug.Print( 1, "Exit : HTTPActionHandler::invoke" );
}
- public void undo(MessageContext msgContext)
+ public void undo(MessageContext msgContext)
{
Debug.Print( 1, "Enter: HTTPActionHandler::undo" );
Debug.Print( 1, "Exit: HTTPActionHandler::undo" );
1.1 xml-axis/java/src/org/apache/axis/handlers/tcp/README
Index: README
===================================================================
This directory is dead!
THIS IS AN EX-DIRECTORY!
1.24 +1 -1 xml-axis/java/src/org/apache/axis/server/AxisServer.java
Index: AxisServer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- AxisServer.java 2001/06/20 12:16:09 1.23
+++ AxisServer.java 2001/06/21 02:45:48 1.24
@@ -236,7 +236,7 @@
if (h == null)
throw new AxisFault("Server.NoService",
"The Axis engine couldn't find a " +
- "target service to invoke!",
+ "target service to invoke! targetService is "+msgContext.getTargetService(),
null, null );
}
1.2 +8 -4 xml-axis/java/src/org/apache/axis/transport/http/HTTPSender.java
Index: HTTPSender.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTTPSender.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HTTPSender.java 2001/06/15 23:16:23 1.1
+++ HTTPSender.java 2001/06/21 02:45:49 1.2
@@ -88,11 +88,13 @@
try {
String host ;
int port = 80 ;
- String action = msgContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
URL tmpURL = new URL( targetURL );
byte[] buf = new byte[4097];
int rc = 0 ;
-
+
+ String action = msgContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
+ if (action == null) action = "";
+
host = tmpURL.getHost();
if ( (port = tmpURL.getPort()) == -1 ) port = 80;
@@ -223,11 +225,13 @@
.append( "\r\n" )
.append( HTTPConstants.HEADER_CONTENT_TYPE )
.append( ": text/xml\r\n" )
- .append( (otherHeaders == null ? "" : otherHeaders.toString()) )
+ .append( (otherHeaders == null ? "" : otherHeaders.toString()))
.append( HTTPConstants.HEADER_SOAP_ACTION )
.append( ": \"" )
.append( action )
- .append( "\"\r\n\r\n" );
+ .append( "\"\r\n");
+
+ header.append("\r\n");
out.write( header.toString().getBytes() );
out.write( reqEnv.getBytes() );
1.17 +5 -4 xml-axis/java/src/org/apache/axis/transport/http/SimpleAxisServer.java
Index: SimpleAxisServer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/SimpleAxisServer.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- SimpleAxisServer.java 2001/06/15 23:16:22 1.16
+++ SimpleAxisServer.java 2001/06/21 02:45:50 1.17
@@ -146,7 +146,7 @@
// create an Axis server
AxisServer engine = new AxisServer();
engine.init();
-
+
// create and initialize a message context
MessageContext msgContext = new MessageContext(engine);
Message requestMsg;
@@ -222,12 +222,13 @@
continue;
}
+ // this may be "" if either SOAPAction: "" or if no SOAPAction at all.
+ // for now, do not complain if no SOAPAction at all
String soapActionString = soapAction.toString();
- requestMsg = new Message(is);
- msgContext.setRequestMessage(requestMsg);
- msgContext.setTargetService(soapActionString);
msgContext.setProperty(HTTPConstants.MC_HTTP_SOAPACTION,
soapActionString);
+ requestMsg = new Message(is);
+ msgContext.setRequestMessage(requestMsg);
msgContext.setProperty(Constants.MC_REALPATH,
fileName.toString());
1.1 xml-axis/java/src/org/apache/axis/transport/tcp/README
Index: README
===================================================================
This directory is dead!
THIS IS AN EX-DIRECTORY!
1.42 +5 -5 xml-axis/java/src/org/apache/axis/utils/Admin.java
Index: Admin.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- Admin.java 2001/06/15 23:16:25 1.41
+++ Admin.java 2001/06/21 02:45:54 1.42
@@ -123,13 +123,13 @@
try {
AxisClassLoader cl = AxisClassLoader.getClassLoader();
- String action = root.getTagName();
-
+ String action = root.getLocalName();
+
if ( !action.equals("deploy") && !action.equals("undeploy") &&
!action.equals("list") && !action.equals("quit") )
throw new AxisFault( "Admin.error",
- "Root element must be 'deploy', 'undeploy' " +
- "or 'list'",
+ "Root element must be 'deploy', 'undeploy', " +
+ "'list', or 'quit'",
null, null );
if (action.equals("quit")) {
@@ -500,7 +500,7 @@
Admin admin = new Admin();
AxisEngine engine;
- if ( args[0].equals("client") )
+ if ( args[0].equals("client") )
engine = new AxisClient();
else
engine = new AxisServer();
1.4 +7 -1 xml-axis/java/test/build_functional_tests.xml
Index: build_functional_tests.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/test/build_functional_tests.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- build_functional_tests.xml 2001/06/01 06:47:59 1.3
+++ build_functional_tests.xml 2001/06/21 02:45:57 1.4
@@ -36,7 +36,7 @@
<!-- =================================================================== -->
<target name="start-functional-test-tcp-server" if="junit.present">
<echo message="Starting test tcp server."/>
- <java classname="org.apache.axis.transport.tcp.AxisListener" fork="yes" dir="./build">
+ <java classname="samples.transport.tcp.TCPListener" fork="yes" dir="./build">
<arg line="-p 8088" /> <!-- arbitrary port -->
<classpath refid="test-classpath" />
</java>
@@ -56,6 +56,12 @@
<!-- Runs the JUnit functional test -->
<!-- =================================================================== -->
<target name="junit-functional" if="junit.present">
+
+ <!-- first, put the JWS where the functional test can see it -->
+ <mkdir dir="build/jws" />
+ <copy file="samples/stock/StockQuoteService.jws" todir="build/jws" />
+
+ <!-- now, run the actual test -->
<junit dir="." printsummary="yes" haltonfailure="yes" fork="yes">
<classpath refid="test-classpath" />
<formatter type="plain" />
1.5 +9 -7 xml-axis/java/test/functional/FunctionalTests.java
Index: FunctionalTests.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/FunctionalTests.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FunctionalTests.java 2001/06/14 07:04:15 1.4
+++ FunctionalTests.java 2001/06/21 02:45:58 1.5
@@ -24,15 +24,17 @@
// BROKEN AS OF RIGHT NOW, 11:26 PST 20010531 -- RobJ
// suite.addTestSuite(TestMiscSample.class);
- // test of the TCP transport
- // ... should be removed?
- suite.addTestSuite(TestTCPEcho.class);
-
- // transport sample test
- suite.addTestSuite(TestTransportSample.class);
-
// stock sample test
+ // run this BEFORE ALL OTHER TESTS to minimize confusion;
+ // this will run the JWS test first, and we want to know that
+ // nothing else has been deployed
suite.addTestSuite(TestStockSample.class);
+
+ // TCP transport sample test
+ suite.addTestSuite(TestTCPTransportSample.class);
+
+ // file transport sample test
+ suite.addTestSuite(TestTransportSample.class);
// bid-buy test
suite.addTestSuite(TestBidBuySample.class);
1.3 +10 -2 xml-axis/java/test/functional/TestStockSample.java
Index: TestStockSample.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/TestStockSample.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestStockSample.java 2001/06/05 12:15:25 1.2
+++ TestStockSample.java 2001/06/21 02:45:59 1.3
@@ -80,9 +80,9 @@
}
public void doTestStockJWS () throws Exception {
- String[] args = { "-uuser1", "-wpass1", "XXX", "-s/axis/StockQuoteService.jws" };
+ String[] args = { "-uuser1", "-wpass1", "XXX", "-sjws/StockQuoteService.jws" };
float val = new GetQuote().getQuote(args);
- assertEquals("TestStockSample.doTestStockJWS(): stock price is 55.25", val, 55.25, 0.01);
+ assertEquals("TestStockSample.doTestStockJWS(): stock price should be 66.25", val, 66.25, 0.01);
}
public void doTestDeploy () throws Exception {
@@ -96,6 +96,12 @@
assertEquals("TestStockSample.doTestStock(): stock price is 55.25", val, 55.25, 0.01);
}
+ public void doTestStockNoAction () throws Exception {
+ String[] args = { "-uuser1", "-wpass1", "XXX_noaction" };
+ float val = new GetQuote().getQuote(args);
+ assertEquals("TestStockSample.doTestStock(): stock price is 55.25", val, 55.25, 0.01);
+ }
+
public void doTestUndeploy () throws Exception {
String[] args = { "samples/stock/undeploy.xml" };
new AdminClient().doAdmin(args);
@@ -111,6 +117,8 @@
doTestDeploy();
System.out.println("Testing service...");
doTestStock();
+ System.out.println("Testing service with SOAPAction: \"\"...");
+ doTestStockNoAction();
System.out.println("Testing undeployment...");
doTestUndeploy();
System.out.println("Test complete.");
1.5 +8 -0 xml-axis/java/test/functional/TestTransportSample.java
Index: TestTransportSample.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/TestTransportSample.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestTransportSample.java 2001/06/15 00:04:18 1.4
+++ TestTransportSample.java 2001/06/21 02:46:00 1.5
@@ -91,11 +91,17 @@
Admin.main(args);
}
+ /* NOT RECOMMENDED -- this calls out to xmltoday.com which is flaky.
+ Do not do this in regular regression tests since it can result in
+ spurious failures due to no fault of Axis code. -- RobJ
+
public void doTestIBM () throws Exception {
String[] args = { "IBM" };
FileTest.main(args);
}
+ */
+
public void doTestXXX () throws Exception {
String[] args = { "XXX" };
FileTest.main(args);
@@ -108,8 +114,10 @@
doTestClientDeploy();
System.out.println("Testing deployment...");
doTestDeploy();
+ /*
System.out.println("Testing service with symbol IBM...");
doTestIBM();
+ */
System.out.println("Testing service with symbol XXX...");
doTestXXX();
System.out.println("Test complete.");
1.1 xml-axis/java/test/functional/TestTCPTransportSample.java
Index: TestTCPTransportSample.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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 test.functional;
import java.net.*;
import java.io.*;
import java.util.*;
import org.apache.axis.AxisFault ;
import samples.transport.tcp.AdminClient;
import samples.transport.tcp.TCPTransport;
import org.apache.axis.client.ServiceClient;
import org.apache.axis.encoding.ServiceDescription;
import org.apache.axis.encoding.SOAPTypeMappingRegistry;
import junit.framework.TestCase;
/** Test the stock sample code.
*/
public class TestTCPTransportSample extends TestCase {
public TestTCPTransportSample(String name) {
super(name);
}
public void doTestDeploy () throws Exception {
String[] args = { "-p8088", "samples/stock/deploy.xml" };
new AdminClient().doAdmin(args);
}
public void doTestUndeploy () throws Exception {
String[] args = { "-p8088", "samples/stock/undeploy.xml" };
new AdminClient().doAdmin(args);
}
public void doTestStock() throws Exception {
try {
System.out.println("Testing TCP stock service...");
String symbol = "XXX"; // args[0] ;
URL url = null;
// parse host, port out of URL by hand
// what to do about that URL format issue.....
try {
url = new URL("http://localhost:8088"); // (opts.getURL());
} catch (IOException ex) {
System.err.println("URL "+url+" hosed: "+ex);
System.exit(1);
}
ServiceClient call = new ServiceClient
( new TCPTransport(url.getHost(), ""+url.getPort()) );
// reconstruct URL
ServiceDescription sd = new ServiceDescription("stockQuotes", true);
sd.addOutputParam("return", SOAPTypeMappingRegistry.XSD_FLOAT);
call.setServiceDescription(sd);
Float res = new Float(0.0F);
// for (int i=0; i<count; i++) {
Object ret = call.invoke(
"urn:xmltoday-delayed-quotes", "getQuote",
new Object[] {symbol} );
if (ret instanceof Float) {
res = (Float) ret;
// System.out.println( symbol + ": " + res );
assertEquals("TestTCPTransportSample: stock price should be 55.25", res.floatValue(), 55.25, 0.000001);
} else {
throw new Exception("Bad return value from TCP stock test: "+ret);
}
}
// }
catch( Exception e ) {
if ( e instanceof AxisFault ) ((AxisFault)e).dump();
e.printStackTrace();
throw new Exception("Fault returned from TCP stock test: "+e);
}
}
public void testTCPTransportSample () throws Exception {
try {
System.out.println("Testing TCP transport.");
System.out.println("Testing deployment...");
doTestDeploy();
System.out.println("Testing service...");
doTestStock();
System.out.println("Testing undeployment...");
doTestUndeploy();
System.out.println("Test complete.");
}
catch( Exception e ) {
if ( e instanceof AxisFault ) ((AxisFault)e).dump();
e.printStackTrace();
throw new Exception("Fault returned from test: "+e);
}
}
}