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 ru...@apache.org on 2001/06/21 16:57:22 UTC
cvs commit: xml-axis/java/src/org/apache/axis/transport/http HTTPSender.java
rubys 01/06/21 07:57:22
Modified: java/samples/stock GetQuote.java
java/src/org/apache/axis/transport/http HTTPSender.java
Log:
Insert code to default SOAPAction, and convert the StockQuote service to
start exploiting the ability to name input parameters and not care about
the name of the output parameters.
***ALL*** I realized I started this with my performance profiling changes,
but we need to start considering the samples as educational materials,
so we need to resist the temptation to put TESTING HACKS in such places.
Revision Changes Path
1.23 +11 -13 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.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- GetQuote.java 2001/06/21 02:45:25 1.22
+++ GetQuote.java 2001/06/21 14:57:14 1.23
@@ -62,7 +62,8 @@
import org.apache.axis.AxisFault ;
import org.apache.axis.client.ServiceClient ;
import org.apache.axis.client.Transport ;
-import org.apache.axis.client.http.HTTPTransport ;
+import org.apache.axis.transport.http.HTTPConstants;
+import org.apache.axis.message.RPCParam ;
import org.apache.axis.utils.Debug ;
import org.apache.axis.utils.Options ;
import org.apache.axis.utils.QName ;
@@ -89,22 +90,21 @@
System.exit(1);
}
- String service = "urn:xmltoday-delayed-quotes";
- String action = service;
+ String namespace = "urn:xmltoday-delayed-quotes";
symbol = args[0] ;
+ ServiceClient call = new ServiceClient(opts.getURL());
+ ServiceDescription sd = new ServiceDescription("stockQuotes", true);
+ sd.addInputParam("symbol", SOAPTypeMappingRegistry.XSD_STRING);
+ sd.setOutputParam(SOAPTypeMappingRegistry.XSD_FLOAT);
+ call.setServiceDescription(sd);
+
// TESTING HACK BY ROBJ
if (symbol.equals("XXX_noaction")) {
symbol = "XXX";
- action = "";
+ call.set(HTTPConstants.MC_HTTP_SOAPACTION, "");
}
- ServiceClient call = new ServiceClient
- (new HTTPTransport(opts.getURL(), action));
- ServiceDescription sd = new ServiceDescription("stockQuotes", true);
- sd.addOutputParam("return", SOAPTypeMappingRegistry.XSD_FLOAT);
- call.setServiceDescription(sd);
-
if ( opts.isFlagSet('t') > 0 ) call.doLocal = true ;
call.set( Transport.USER, opts.getUser() );
@@ -121,10 +121,8 @@
Float res = new Float(0.0F);
for (int i=0; i<count; i++) {
- // the namespace of the call should be the service.
- // ...according to Glen... -- RobJ
Object ret = call.invoke(
- service, "getQuote", new Object[] {symbol} );
+ namespace, "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.3 +8 -2 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HTTPSender.java 2001/06/21 02:45:49 1.2
+++ HTTPSender.java 2001/06/21 14:57:19 1.3
@@ -64,6 +64,7 @@
import org.apache.axis.utils.* ;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPHeader;
+import org.apache.axis.message.MessageElement;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.transport.http.NonBlockingBufferedInputStream;
import org.apache.axis.encoding.Base64 ;
@@ -92,8 +93,13 @@
byte[] buf = new byte[4097];
int rc = 0 ;
- String action = msgContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
- if (action == null) action = "";
+ // default SOAPAction to request namespaceURI/method
+ String action = msgContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
+ if (action == null) {
+ Message rm = msgContext.getRequestMessage();
+ MessageElement body = rm.getAsSOAPEnvelope().getFirstBody();
+ action = body.getNamespaceURI() + "/" + body.getName();
+ }
host = tmpURL.getHost();
if ( (port = tmpURL.getPort()) == -1 ) port = 80;