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 he...@apache.org on 2005/02/14 05:02:21 UTC
svn commit: r153707 [1/2] - in
webservices/axis/trunk/java/dev/scratch/prototype2: ./ src/conf/
src/java/org/apache/axis/clientapi/ src/java/org/apache/axis/context/
src/java/org/apache/axis/description/ src/java/org/apache/axis/engine/
src/java/org/apache/axis/providers/ src/java/org/apache/axis/transport/
src/java/org/apache/axis/transport/http/
src/java/org/apache/axis/transport/tcp/ src/samples/encoding/sample1/src/
src/test-resources/ src/test/org/apache/axis/clientapi/
src/test/org/apache/axis/engine/ src/test/org/apache/axis/integration/
src/test/org/apache/axis/testUtils/ src/test/org/apache/axis/transport/
Author: hemapani
Date: Sun Feb 13 20:02:14 2005
New Revision: 153707
URL: http://svn.apache.org/viewcvs?view=rev&rev=153707
Log:
make the call transport independent and remove the URL and add code the parse the HTTP headers
Added:
webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/commons-logging.properties (with props)
webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/log4j.properties (with props)
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciver.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciverLocator.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSender.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSenderLocator.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportReciver.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/SimpleHTTPServer.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/transport/
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/transport/HTTPTrasportHeaderParsingTest.java
Removed:
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/TransportSender.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/TransportSenderLocator.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTransportReceiver.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/SimpleHTTPReceiver.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/tcp/
Modified:
webservices/axis/trunk/java/dev/scratch/prototype2/maven.xml
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/AbstractCall.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Call.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Invoker.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/providers/RawXMLProvider.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTransportSender.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPConstants.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportSender.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadIncreaseTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/Sampler.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceive.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/clientapi/TestSendReceiveAsync.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/CallUnregisterdServiceTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoRawXMLTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EchoTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/EngineUtils.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/HandlerFaliureTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/MessageContextTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/engine/MessageWithServerTest.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/integration/UtilServer.java
webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/testUtils/SimpleTypeEncoder.java
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/maven.xml?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/maven.xml (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/maven.xml Sun Feb 13 20:02:14 2005
@@ -43,9 +43,41 @@
<lib dir="target/">
<include name="axis2*.jar"/>
</lib>
+ <classes dir="src/conf">
+ <include name="*.properties"/>
+ </classes>
</war>
</goal>
+ <goal name="war-withsamples" prereqs="jar">
+ <!-- jar the test classes -->
+ <jar destfile="target/axis2-test.jar" basedir="target/test-classes"/>
+ <war destfile="target/axis2.war" webxml="src/conf/web.xml">
+ <fileset dir="src/html"/>
+ <webinf dir="target/test-resources/samples"/>
+ <lib dir="${maven.repo.local}/stax/jars/">
+ <include name="stax-api-1.0.jar"/>
+ <include name="stax-1.1.1-dev.jar"/>
+ </lib>
+ <lib dir="${maven.repo.local}/commons-logging/jars/">
+ <include name="commons-logging-1.0.3.jar"/>
+ </lib>
+ <lib dir="${maven.repo.local}/axis/jars/">
+ <include name="axis-wsdl4j-1.2-RC1.jar"/>
+ </lib>
+ <lib dir="${maven.repo.local}/log4j/jars/">
+ <include name="log4j-1.2.8.jar"/>
+ </lib>
+ <lib dir="target/">
+ <include name="axis2*.jar"/>
+ </lib>
+ <classes dir="src/conf">
+ <include name="*.properties"/>
+ </classes>
+ </war>
+ </goal>
+
+
<goal name="samples">
<ant:ant antfile="build.xml" inheritall="true" inheritrefs="true" dir="src/samples/encoding/sample1"/>
<ant:ant antfile="build.xml" inheritall="true" inheritrefs="true" dir="src/samples/encoding/sample2"/>
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/commons-logging.properties
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/commons-logging.properties?view=auto&rev=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/commons-logging.properties (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/commons-logging.properties Sun Feb 13 20:02:14 2005
@@ -0,0 +1,11 @@
+# This is the logging properties that goes to the war, there are two logging conf kept at the
+# svn, one for developement (one at src/test-resources) and other for producation
+
+# Uncomment the next line to disable all logging.
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
+
+# Uncomment the next line to enable the simple log based logging
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
+
+# Uncomment the next line to enable log4j based logging
+org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
Propchange: webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/commons-logging.properties
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/log4j.properties
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/log4j.properties?view=auto&rev=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/log4j.properties (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/log4j.properties Sun Feb 13 20:02:14 2005
@@ -0,0 +1,18 @@
+## Use two appenders, one to log to console, another to log to a file
+# This is the logging properties that goes to the war, there are two logging conf kept at the
+# svn, one for developement (one at src/test-resources) and other for producation
+
+log4j.rootCategory=ERROR, LOGFILE
+
+#### appender writes to a file
+log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
+log4j.appender.LOGFILE.File=axis.log
+
+# Control the maximum log file size
+log4j.appender.LOGFILE.MaxFileSize=10000KB
+# Archive log files (one backup file here)
+log4j.appender.LOGFILE.MaxBackupIndex=100
+
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%6r %5p [%t] (%F:%L) - %m%n
+
Propchange: webservices/axis/trunk/java/dev/scratch/prototype2/src/conf/log4j.properties
------------------------------------------------------------------------------
svn:executable = *
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/AbstractCall.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/AbstractCall.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/AbstractCall.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/AbstractCall.java Sun Feb 13 20:02:14 2005
@@ -32,18 +32,18 @@
public abstract class AbstractCall {
- public MessageContext createIncomingMessageContext(InputStream in, EngineRegistry reg) throws AxisFault {
- MessageContext msgContext;
- try {
- msgContext = new MessageContext(reg);
- InputStreamReader isr = new InputStreamReader(in);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(isr);
- StAXBuilder builder = new StAXSOAPModelBuilder(OMFactory.newInstance(), reader);
- msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
- } catch (XMLStreamException e) {
- throw AxisFault.makeFault(e);
- }
- return msgContext;
-
- }
+// public MessageContext createIncomingMessageContext(InputStream in, EngineRegistry reg) throws AxisFault {
+// MessageContext msgContext;
+// try {
+// msgContext = new MessageContext(reg);
+// InputStreamReader isr = new InputStreamReader(in);
+// XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(isr);
+// StAXBuilder builder = new StAXSOAPModelBuilder(OMFactory.newInstance(), reader);
+// msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
+// } catch (XMLStreamException e) {
+// throw AxisFault.makeFault(e);
+// }
+// return msgContext;
+//
+// }
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Call.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Call.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Call.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Call.java Sun Feb 13 20:02:14 2005
@@ -12,9 +12,11 @@
import org.apache.axis.engine.AxisFault;
import org.apache.axis.engine.EngineRegistry;
import org.apache.axis.engine.EngineRegistryImpl;
-import org.apache.axis.engine.TransportSenderLocator;
import org.apache.axis.om.OMException;
import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.transport.TransportReciver;
+import org.apache.axis.transport.TransportReciverLocator;
+import org.apache.axis.transport.TransportSenderLocator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -44,13 +46,12 @@
private String transport;
private String action;
-
public Call() {
//TODO look for the Client XML and creatre a Engine registy
this.registry = new EngineRegistryImpl(new AxisGlobal());
}
- public void setTo(EndpointReference EPR){
+ public void setTo(EndpointReference EPR) {
this.targetEPR = EPR;
}
@@ -60,7 +61,7 @@
* inoder to have asyn support for tansport , it shoud call this method
* @param transport
*/
- public void setListenerTransport(String transport, boolean blocked){
+ public void setListenerTransport(String transport, boolean blocked) {
this.blocked = blocked;
this.transport = transport;
}
@@ -68,17 +69,17 @@
* todo
* @param action
*/
- public void setAction(String action){
+ public void setAction(String action) {
this.action = action;
}
-
/**
* Fire and forget MEP
* todo
* @param envelope
*/
public void sendAsync(SOAPEnvelope envelope) throws AxisFault {
+ OutputStream out = null;
try {
URL url = new URL(targetEPR.getAddress());
@@ -87,74 +88,80 @@
final AxisEngine engine = new AxisEngine(registry);
urlConnect.setDoOutput(true);
-
- MessageContext msgctx = new MessageContext(registry);
+ MessageContext msgctx = new MessageContext(registry,null);
msgctx.setEnvelope(envelope);
- OutputStream out = urlConnect.getOutputStream();
- msgctx.setProperty(MessageContext.TRANSPORT_DATA, out);
- msgctx.setProperty(MessageContext.TRANSPORT_TYPE, TransportSenderLocator.TRANSPORT_HTTP);
+ out = urlConnect.getOutputStream();
+ msgctx.setProperty(MessageContext.TRANSPORT_WRITER, out);
+ msgctx.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
msgctx.setTo(targetEPR);
engine.send(msgctx);
- }catch (IOException e){
+ } catch (IOException e) {
throw AxisFault.makeFault(e);
+ } finally {
+ try {
+ out.close();
+ } catch (IOException e1) {
+ throw new AxisFault();
+ }
}
}
public void send(SOAPEnvelope envelope) throws AxisFault {
- try{
- URL url =new URL(targetEPR.getAddress());
- final URLConnection urlConnect;
- urlConnect = url.openConnection();
+ try {
final AxisEngine engine = new AxisEngine(registry);
- urlConnect.setDoOutput(true);
-
- MessageContext msgctx = new MessageContext(registry);
+ MessageContext msgctx = new MessageContext(registry,null);
msgctx.setEnvelope(envelope);
- OutputStream out = urlConnect.getOutputStream();
- msgctx.setProperty(MessageContext.TRANSPORT_DATA, out);
- msgctx.setProperty(MessageContext.TRANSPORT_TYPE, TransportSenderLocator.TRANSPORT_HTTP);
+ msgctx.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
msgctx.setTo(targetEPR);
engine.send(msgctx);
//todo dose the 202 response come throgh the same connection
//This is purely HTTP specific.
- MessageContext response = createIncomingMessageContext(urlConnect.getInputStream(), registry);
- response.setServerSide(false);
- engine.receive(response);
+ //Handle the HTTP 202 respose
+ MessageContext response = new MessageContext(registry,msgctx.getProperties());
- }catch (IOException e){
+ response.setServerSide(false);
+ response.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
+ TransportReciver reciver = TransportReciverLocator.locate(response);
+ reciver.invoke(response);
+ } catch (IOException e) {
throw AxisFault.makeFault(e);
}
}
- public SOAPEnvelope sendReceive(SOAPEnvelope envelope) throws AxisFault {
- try{
+ public SOAPEnvelope sendReceive(SOAPEnvelope envelope) throws AxisFault {
+ try {
AxisEngine engine = new AxisEngine(registry);
- MessageContext msgctx = new MessageContext(registry);
+ MessageContext msgctx = new MessageContext(registry,null);
msgctx.setEnvelope(envelope);
- // TODO : Below par is transport specific, for the time being its HTTP. It should be modified
- // so that correct transport sender should be created here
- URL url =new URL(targetEPR.getAddress());
- URLConnection urlConnect = url.openConnection();
- urlConnect.setDoOutput(true);
- OutputStream out = urlConnect.getOutputStream();
-
- msgctx.setProperty(MessageContext.TRANSPORT_DATA, out);
- msgctx.setProperty(MessageContext.TRANSPORT_TYPE, TransportSenderLocator.TRANSPORT_HTTP);
+ msgctx.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
msgctx.setTo(targetEPR);
+
engine.send(msgctx);
- MessageContext response = createIncomingMessageContext(urlConnect.getInputStream(), registry);
- response.setServerSide(false);
- engine.receive(response);
+ MessageContext response = new MessageContext(registry,msgctx.getProperties());
+ response.setServerSide(false);
+ response.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
+ TransportReciver reciver = TransportReciverLocator.locate(response);
+ reciver.invoke(response);
SOAPEnvelope resenvelope = response.getEnvelope();
return resenvelope;
@@ -170,26 +177,32 @@
* @param envelope
* @param callback
*/
- public void sendReceiveAsync(SOAPEnvelope envelope, final Callback callback) throws AxisFault {
- try{
- // URL url =new URL(targetEPR.getAddress());
+ public void sendReceiveAsync(
+ SOAPEnvelope envelope,
+ final Callback callback)
+ throws AxisFault {
+ try {
+ // URL url =new URL(targetEPR.getAddress());
AxisEngine engine = new AxisEngine(registry);
- final MessageContext msgctx = new MessageContext(registry);
+ final MessageContext msgctx = new MessageContext(registry,null);
msgctx.setEnvelope(envelope);
- msgctx.setProperty(MessageContext.TRANSPORT_TYPE, TransportSenderLocator.TRANSPORT_HTTP);
+ msgctx.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
msgctx.setTo(targetEPR);
-
- // only the transport blocked , client dose not hang
- if(blocked){
+
+ // only the transport blocked , client dose not hang
+ if (blocked) {
//TODO This shoudld be taken from a pool of inovkers.
- Invoker invoker = new Invoker(msgctx,engine,registry,callback);
+ Invoker invoker =
+ new Invoker(msgctx, engine, registry, callback);
Thread th = new Thread(invoker);
th.start();
} else {
- //TODO
- //start the Listener at the client side
-
+ //TODO
+ //start the Listener at the client side
+
}
} catch (OMException e) {
throw AxisFault.makeFault(e);
@@ -197,7 +210,6 @@
throw AxisFault.makeFault(e);
}
}
-
public Object getTO() {
return this.targetEPR;
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Invoker.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Invoker.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Invoker.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/clientapi/Invoker.java Sun Feb 13 20:02:14 2005
@@ -11,13 +11,12 @@
* governing permissions and limitations under the License.
*/
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLConnection;
-
import org.apache.axis.context.MessageContext;
import org.apache.axis.engine.AxisEngine;
import org.apache.axis.engine.EngineRegistry;
+import org.apache.axis.transport.TransportReciver;
+import org.apache.axis.transport.TransportReciverLocator;
+import org.apache.axis.transport.TransportSenderLocator;
public class Invoker extends AbstractCall implements Runnable {
@@ -28,7 +27,11 @@
private Callback callback;
- public Invoker(MessageContext msgContext, AxisEngine engine,EngineRegistry reg, Callback callback) {
+ public Invoker(
+ MessageContext msgContext,
+ AxisEngine engine,
+ EngineRegistry reg,
+ Callback callback) {
this.engine = engine;
this.reqMsgContext = msgContext;
this.callback = callback;
@@ -40,26 +43,29 @@
final Correlator correlator = Correlator.getInstance();
final String messageID = Long.toString(System.currentTimeMillis());
try {
- URL url = new URL(reqMsgContext.getTo().getAddress());
- URLConnection urlConnect = url.openConnection();
- urlConnect.setDoOutput(true);
- OutputStream out = urlConnect.getOutputStream();
- reqMsgContext.setProperty(MessageContext.TRANSPORT_DATA, out);
reqMsgContext.setMessageID(messageID);
engine.send(reqMsgContext);
- correlator.addCorrelationInfo(reqMsgContext.getMessageID(), callback);
+ correlator.addCorrelationInfo(
+ reqMsgContext.getMessageID(),
+ callback);
+
+ MessageContext resMsgContext = new MessageContext(registry,reqMsgContext.getProperties());
- MessageContext resMsgContext = createIncomingMessageContext(
- urlConnect.getInputStream(), registry);
resMsgContext.setServerSide(false);
- engine.receive(resMsgContext);
+ resMsgContext.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
+ TransportReciver reciver =
+ TransportReciverLocator.locate(resMsgContext);
+ reciver.invoke(resMsgContext);
AsyncResult result = new AsyncResult();
result.setResult(resMsgContext.getEnvelope());
resMsgContext.setMessageID(messageID);
- callback = correlator.getCorrelationInfo(resMsgContext.getMessageID());
+ callback =
+ correlator.getCorrelationInfo(resMsgContext.getMessageID());
callback.onComplete(result);
} catch (Exception e) {
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/context/MessageContext.java Sun Feb 13 20:02:14 2005
@@ -29,6 +29,7 @@
import org.apache.axis.om.SOAPEnvelope;
import java.util.HashMap;
+import java.util.Map;
import javax.xml.stream.XMLStreamReader;
@@ -46,7 +47,9 @@
public static final String PASSWORD = "PASSWD";
public static final String TRANSPORT_TYPE = "TRANSPORT_TYPE";
public static final String SOAP_ACTION = "SOAP_ACTION";
- public static final String TRANSPORT_DATA = "TRANSPORT_DATA";
+ public static final String TRANSPORT_WRITER = "TRANSPORT_WRITER";
+ public static final String TRANSPORT_READER = "TRANSPORT_READER";
+ public static final String TRANSPORT_IN = "TRANSPORT_IN";
//public static final String REQUEST_URL = "REQUEST_URL";
private boolean processingFault = false;
@@ -61,7 +64,7 @@
//there is a no use cas found to set those proprties
//so declare them final
- private final HashMap properties;
+ private final Map properties;
private final GlobalContext globalContext;
private SessionContext sessionContext;
@@ -76,10 +79,13 @@
private XMLStreamReader xpp;
private OMElement soapOperationElement;
- public MessageContext(EngineRegistry er) throws AxisFault {
+ public MessageContext(EngineRegistry er, Map initialProperties) throws AxisFault {
this.globalContext = new GlobalContext(er);
this.sessionContext = new SimpleSessionContext();
- properties = new HashMap();
+ if(initialProperties == null){
+ initialProperties = new HashMap();
+ }
+ properties = initialProperties;
chain = new ExecutionChain();
}
@@ -389,5 +395,12 @@
public void setSoapOperationElement(OMElement element) {
soapOperationElement = element;
}
+
+ /**
+ * @return
+ */
+ public Map getProperties() {
+ return properties;
+ }
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/description/AxisGlobal.java Sun Feb 13 20:02:14 2005
@@ -17,7 +17,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Vector;
import java.util.List;
import javax.xml.namespace.QName;
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/engine/AxisEngine.java Sun Feb 13 20:02:14 2005
@@ -22,6 +22,7 @@
import org.apache.axis.description.AxisTransport;
import org.apache.axis.om.OMFactory;
import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.transport.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -130,7 +131,7 @@
chain.addPhases(transport.getPhases(flow));
}
Phase sendPhase = new Phase(Phase.SENDING_PHASE);
- sendPhase.addHandler(TransportSenderLocator.locateTransPortSender(context));
+ sendPhase.addHandler(TransportSenderLocator.locate(context));
chain.addPhase(sendPhase);
//startet rolling
chain.invoke(context);
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/providers/RawXMLProvider.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/providers/RawXMLProvider.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/providers/RawXMLProvider.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/providers/RawXMLProvider.java Sun Feb 13 20:02:14 2005
@@ -114,7 +114,7 @@
Object[] parms = new Object[]{parmeter};
//invoke the WebService
OMElement result = (OMElement) method.invoke(obj, parms);
- MessageContext msgContext1 = new MessageContext(msgContext.getGlobalContext().getRegistry());
+ MessageContext msgContext1 = new MessageContext(msgContext.getGlobalContext().getRegistry(),msgContext.getProperties());
SOAPEnvelope envelope = OMFactory.newInstance().getDefaultEnvelope();
envelope.getBody().setFirstChild(result);
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTransportSender.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTransportSender.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/AbstractTransportSender.java Sun Feb 13 20:02:14 2005
@@ -17,6 +17,7 @@
package org.apache.axis.transport;
import java.io.OutputStream;
+import java.io.Writer;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLOutputFactory;
@@ -26,7 +27,6 @@
import org.apache.axis.context.MessageContext;
import org.apache.axis.description.HandlerMetaData;
import org.apache.axis.engine.AxisFault;
-import org.apache.axis.engine.TransportSender;
import org.apache.axis.handlers.AbstractHandler;
import org.apache.axis.om.SOAPEnvelope;
import org.apache.commons.logging.Log;
@@ -34,64 +34,84 @@
/**
*/
-public abstract class AbstractTransportSender extends AbstractHandler implements TransportSender {
- private Log log = LogFactory.getLog(getClass());
- public static final QName NAME = new QName("http://axis.ws.apache.org","TransportSender");
-
- public AbstractTransportSender(){
- init(new HandlerMetaData(NAME));
- }
- public final void invoke(MessageContext msgContext) throws AxisFault {
- OutputStream out = null;
+public abstract class AbstractTransportSender
+ extends AbstractHandler
+ implements TransportSender {
+ private Log log = LogFactory.getLog(getClass());
+ public static final QName NAME =
+ new QName("http://axis.ws.apache.org", "TransportSender");
+ protected OutputStream outS;
+ public AbstractTransportSender() {
+ init(new HandlerMetaData(NAME));
+ }
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Writer out = null;
if (msgContext.isProcessingFault()) {
//Means we are processing fault
if (msgContext.getFaultTo() != null) {
- log.info("Obtain the output stream to send the fault flow to " + msgContext.getFaultTo().getAddress());
+ log.info(
+ "Obtain the output stream to send the fault flow to "
+ + msgContext.getFaultTo().getAddress());
out = obtainOutputStream(msgContext, msgContext.getFaultTo());
} else {
- log.info("Obtain the output stream to send the fault flow to ANONYMOUS");
+ log.info(
+ "Obtain the output stream to send the fault flow to ANONYMOUS");
out = obtainOutputStream(msgContext);
}
} else {
if (msgContext.getTo() != null) {
- log.info("Obtain the output stream to send to To flow to " + msgContext.getTo().getAddress());
+ log.info(
+ "Obtain the output stream to send to To flow to "
+ + msgContext.getTo().getAddress());
out = obtainOutputStream(msgContext, msgContext.getTo());
} else if (msgContext.getReplyTo() != null) {
- log.info("Obtain the output stream to send to ReplyTo flow to " + msgContext.getReplyTo().getAddress());
+ log.info(
+ "Obtain the output stream to send to ReplyTo flow to "
+ + msgContext.getReplyTo().getAddress());
out = obtainOutputStream(msgContext, msgContext.getTo());
} else {
- log.info("Obtain the output stream to send the fault flow to ANONYMOUS");
+ log.info(
+ "Obtain the output stream to send the fault flow to ANONYMOUS");
out = obtainOutputStream(msgContext);
}
}
- startSending();
+ startSending(msgContext);
SOAPEnvelope envelope = msgContext.getEnvelope();
if (envelope != null) {
- XMLStreamWriter outputWriter = null;
+ XMLStreamWriter outputWriter = null;
try {
- // org.TimeRecorder.BEFORE_SERIALIZE = System.currentTimeMillis();
- outputWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
- // envelope.serialize(outputWriter,false);
- envelope.serialize(outputWriter,false);
+ // org.TimeRecorder.BEFORE_SERIALIZE = System.currentTimeMillis();
+ outputWriter =
+ XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+ envelope.serialize(outputWriter, false);
outputWriter.flush();
-
- // org.TimeRecorder.AFTER_SERIALIZE = System.currentTimeMillis();
+ if (outS != null) {
+ outS.flush();
+ } else {
+ out.flush();
+ }
+ // org.TimeRecorder.AFTER_SERIALIZE = System.currentTimeMillis();
} catch (Exception e) {
- throw new AxisFault("Stream error",e);
+ throw new AxisFault("Stream error", e);
}
}
-
- finalizeSending();
- log.info("Send the Response");
+
+ finalizeSending(msgContext);
+ log.info("Send the Response");
}
- protected void startSending() {
+ protected void startSending(MessageContext msgContext) throws AxisFault {
}
- protected abstract OutputStream obtainOutputStream(MessageContext msgContext, EndpointReference epr) throws AxisFault;
+ protected abstract Writer obtainOutputStream(
+ MessageContext msgContext,
+ EndpointReference epr)
+ throws AxisFault;
- protected abstract OutputStream obtainOutputStream(MessageContext msgContext) throws AxisFault;
+ protected abstract Writer obtainOutputStream(MessageContext msgContext)
+ throws AxisFault;
- protected void finalizeSending() {
+ protected void finalizeSending(MessageContext msgContext)
+ throws AxisFault {
}
}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciver.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciver.java?view=auto&rev=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciver.java (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciver.java Sun Feb 13 20:02:14 2005
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis.transport;
+
+import org.apache.axis.handlers.AbstractHandler;
+
+public abstract class TransportReciver extends AbstractHandler{
+}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciverLocator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciverLocator.java?view=auto&rev=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciverLocator.java (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportReciverLocator.java Sun Feb 13 20:02:14 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis.transport;
+
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.transport.http.HTTPTransportReciver;
+
+public class TransportReciverLocator {
+ public static final String TRANSPORT_TCP = "tcp";
+ public static final String TRANSPORT_HTTP = "http";
+
+ public static TransportReciver locate(MessageContext msgContext)
+ throws AxisFault {
+ String type =
+ (String) msgContext.getProperty(MessageContext.TRANSPORT_TYPE);
+ if (TransportReciverLocator.TRANSPORT_HTTP.equals(type)) {
+ return new HTTPTransportReciver();
+ }else{
+ throw new AxisFault("No tranport found");
+ }
+ }
+}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSender.java?view=auto&rev=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSender.java (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSender.java Sun Feb 13 20:02:14 2005
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis.transport;
+
+import org.apache.axis.engine.Handler;
+
+public interface TransportSender extends Handler {
+}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSenderLocator.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSenderLocator.java?view=auto&rev=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSenderLocator.java (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/TransportSenderLocator.java Sun Feb 13 20:02:14 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis.transport;
+
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.transport.http.HTTPTransportSender;
+
+
+public class TransportSenderLocator {
+ public static final String TRANSPORT_TCP = "tcp";
+ public static final String TRANSPORT_HTTP = "http";
+
+ public static TransportSender locate(MessageContext msgContext) throws AxisFault {
+ String type = (String) msgContext.getProperty(MessageContext.TRANSPORT_TYPE);
+ if (TransportSenderLocator.TRANSPORT_HTTP.equals(type)) {
+ return new HTTPTransportSender();
+ }
+ throw new AxisFault("No tranport found");
+ }
+}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/AxisServlet.java Sun Feb 13 20:02:14 2005
@@ -18,12 +18,10 @@
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.OutputStream;
import java.io.PrintWriter;
-import java.util.Iterator;
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
+import java.util.Iterator;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -39,17 +37,17 @@
import org.apache.axis.addressing.AddressingConstants;
import org.apache.axis.addressing.EndpointReference;
import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.AxisOperation;
+import org.apache.axis.description.AxisService;
import org.apache.axis.engine.AxisEngine;
import org.apache.axis.engine.AxisFault;
import org.apache.axis.engine.EngineRegistry;
import org.apache.axis.engine.EngineRegistryFactory;
-import org.apache.axis.engine.TransportSenderLocator;
import org.apache.axis.om.OMFactory;
import org.apache.axis.om.SOAPEnvelope;
import org.apache.axis.om.impl.llom.builder.StAXBuilder;
import org.apache.axis.om.impl.llom.builder.StAXSOAPModelBuilder;
-import org.apache.axis.description.AxisService;
-import org.apache.axis.description.AxisOperation;
+import org.apache.axis.transport.TransportSenderLocator;
@@ -76,7 +74,7 @@
try {
res.setContentType("text/xml; charset=utf-8");
AxisEngine engine = new AxisEngine(engineRegistry);
- MessageContext msgContext = new MessageContext(engineRegistry);
+ MessageContext msgContext = new MessageContext(engineRegistry,null);
msgContext.setServerSide(true);
String filePart = req.getRequestURL().toString();
if(filePart != null && filePart.endsWith(LISTSERVICES)) {
@@ -91,13 +89,21 @@
msgContext.setProperty(MessageContext.SOAP_ACTION, soapActionString);
}
- InputStreamReader isr = new InputStreamReader(req.getInputStream());
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(isr);
- StAXBuilder builder = new StAXSOAPModelBuilder(OMFactory.newInstance(), reader);
- msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
+ XMLStreamReader reader =
+ XMLInputFactory.newInstance().createXMLStreamReader(new InputStreamReader(
+ req.getInputStream()));
+ StAXBuilder builder =
+ new StAXSOAPModelBuilder(OMFactory.newInstance(), reader);
+ msgContext.setEnvelope((SOAPEnvelope) builder.getDocumentElement());
+
+ msgContext.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
+ msgContext.setProperty(
+ MessageContext.TRANSPORT_WRITER,
+ res.getWriter());
- storeOutputInfo(msgContext, res.getOutputStream());
- engine.receive(msgContext);
+ engine.receive(msgContext);
} catch (AxisFault e) {
throw new ServletException(e);
} catch (XMLStreamException e) {
@@ -108,22 +114,7 @@
}
- protected void storeOutputInfo(MessageContext msgContext,
- OutputStream out) throws AxisFault {
-// try {
- // Send it on its way...
-// out.write(HTTPConstants.HTTP);
-// out.write(HTTPConstants.OK);
-// out.write("\n\n".getBytes());
- //We do not have any Addressing Headers to put
- //let us put the information about incoming transport
- msgContext.setProperty(MessageContext.TRANSPORT_TYPE,
- TransportSenderLocator.TRANSPORT_HTTP);
- msgContext.setProperty(MessageContext.TRANSPORT_DATA, out);
-// } catch (IOException e) {
-// throw AxisFault.makeFault(e);
-// }
- }
+
private void listServices(HttpServletResponse res) throws IOException {
HashMap services = engineRegistry.getServices();
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPConstants.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPConstants.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPConstants.java Sun Feb 13 20:02:14 2005
@@ -26,6 +26,14 @@
* whaddya think? - todo by Jacek)
*/
+ public static final String PROTOCOL_VERSION = "PROTOCOL";
+ public static final String REQUEST_URI = "REQUEST_URI";
+ public static final String RESPONSE_CODE = "RESPONSE_CODE";
+ public static final String RESPONSE_WORD = "RESPONSE_WORD";
+ public static final String RESPONSE_ACK_CODE_VAL = "202";
+ public static final String SOCKET = "SOCKET";
+
+
public static final String HEADER_PROTOCOL_10 = "HTTP/1.0";
public static final String HEADER_PROTOCOL_11 = "HTTP/1.1";
public static final String HEADER_PROTOCOL_V10 = "1.0".intern();
@@ -123,13 +131,13 @@
public static final String PLUGIN_EXCEPTION_LOG = "transport.http.plugin.exceptionLog";
- public static final byte OK[] = ("200 OK").getBytes();
+ public static final char OK[] = ("200 OK").toCharArray();
public static final byte NOCONTENT[] = ("202 OK\n\n").getBytes();
public static final byte UNAUTH[] = ("401 Unauthorized").getBytes();
public static final byte SENDER[] = "400".getBytes();
public static final byte ISE[] = ("500 Internal server error").getBytes();
// HTTP prefix
- public static byte HTTP[] = "HTTP/1.0 ".getBytes();
+ public static char HTTP[] = "HTTP/1.0 ".toCharArray();
}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportReciver.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportReciver.java?view=auto&rev=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportReciver.java (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportReciver.java Sun Feb 13 20:02:14 2005
@@ -0,0 +1,394 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis.transport.http;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.engine.AxisEngine;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.SOAPEnvelope;
+import org.apache.axis.om.impl.llom.builder.StAXBuilder;
+import org.apache.axis.om.impl.llom.builder.StAXSOAPModelBuilder;
+import org.apache.axis.transport.TransportReciver;
+
+public class HTTPTransportReciver extends TransportReciver {
+
+ private static final int END = 1;
+ private static final int END_OF_LINE = 2;
+ private static final int BEFORE_SEPERATOR = 3;
+ private static final int AFTER_SEPERATOR = 4;
+ private int lastRead = -1;
+
+ private char[] buf = new char[1024];
+ int index = 0;
+ int length = 0;
+ private boolean done = false;
+
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ Reader in =
+ (Reader) msgContext.getProperty(
+ MessageContext.TRANSPORT_READER);
+ if (in != null) {
+ boolean serverSide = msgContext.isServerSide();
+ Map map = parseTheHeaders(in, serverSide);
+ if (serverSide) {
+ msgContext.setProperty(
+ MessageContext.SOAP_ACTION,
+ map.get(HTTPConstants.HEADER_SOAP_ACTION));
+ msgContext.setTo(
+ new EndpointReference(
+ AddressingConstants.WSA_TO,
+ (String) map.get(HTTPConstants.REQUEST_URI)));
+ //TODO see is it a Service request e.g. WSDL, list ....
+ // TODO take care of the other HTTPHeaders
+
+ } else {
+ if(HTTPConstants.RESPONSE_ACK_CODE_VAL.equals(map.get(HTTPConstants.RESPONSE_CODE))){
+ //This is Ack
+ return;
+ }
+ //TODO take care of other HTTP Headers
+ }
+ AxisEngine axisEngine =
+ new AxisEngine(msgContext.getGlobalContext().getRegistry());
+ try {
+ XMLStreamReader xmlreader =
+ XMLInputFactory.newInstance().createXMLStreamReader(in);
+ StAXBuilder builder =
+ new StAXSOAPModelBuilder(
+ OMFactory.newInstance(),
+ xmlreader);
+ msgContext.setEnvelope(
+ (SOAPEnvelope) builder.getDocumentElement());
+ } catch (Exception e) {
+ throw new AxisFault(e.getMessage(),e);
+ }
+
+ axisEngine.receive(msgContext);
+ } else {
+ throw new AxisFault("Input reader not found");
+ }
+
+ }
+
+ /** parses following two styles of HTTP stuff
+ Server Side
+ POST /axis2/services/echo HTTP/1.0
+ Content-Type: text/xml; charset=utf-8
+ Accept: application/soap+xml, application/dime, multipart/related, text/*
+ User-Agent: Axis/1.2RC1
+ Host: 127.0.0.1:8081
+ Cache-Control: no-cache
+ Pragma: no-cache
+ SOAPAction: ""
+ Content-Length: 73507
+
+ HTTP/1.1 200 OK
+ Content-Type: text/xml;charset=utf-8
+ Date: Sat, 12 Feb 2005 10:39:39 GMT
+ Server: Apache-Coyote/1.1
+ Connection: close
+
+
+ * @param reader
+ * @return
+ */
+
+ public HashMap parseTheHeaders(Reader reader, boolean serverSide)
+ throws AxisFault {
+ HashMap map = new HashMap();
+ try {
+
+ StringBuffer str = new StringBuffer();
+
+ int state = BEFORE_SEPERATOR;
+
+ String key = null;
+ String value = null;
+
+ int start = 0;
+
+ length = readLine(reader, buf);
+ if (serverSide) {
+ if (buf[0] == 'P'
+ && buf[1] == 'O'
+ && buf[2] == 'S'
+ && buf[3] == 'T') {
+ index = 5;
+ value = readFirstLineArg(' ');
+ map.put(HTTPConstants.REQUEST_URI, value);
+ value = readFirstLineArg('\n');
+ map.put(HTTPConstants.PROTOCOL_VERSION, value);
+ } else {
+ throw new AxisFault("Only the POST requests are supported");
+ }
+ } else {
+ index = 0;
+ value = readFirstLineArg(' ');
+ map.put(HTTPConstants.PROTOCOL_VERSION, value);
+ value = readFirstLineArg(' ');
+ map.put(HTTPConstants.RESPONSE_CODE, value);
+ value = readFirstLineArg('\n');
+ map.put(HTTPConstants.RESPONSE_WORD, value);
+ }
+
+ state = BEFORE_SEPERATOR;
+
+
+ while (!done) {
+ length = readLine(reader, buf);
+ if (length <= 0) {
+ throw new AxisFault("Premature end of steam");
+ }
+ for (int i = 0; i < length; i++) {
+ switch (state) {
+ case BEFORE_SEPERATOR :
+ if (buf[i] == ':') {
+ key = str.toString();
+ str = new StringBuffer();
+ state = AFTER_SEPERATOR;
+
+ if (buf[i + 1] == ' ') {
+ i++; //ignore next space
+ }
+ } else {
+ str.append(buf[i]);
+ }
+ break;
+ case AFTER_SEPERATOR :
+ if (buf[i] == '\n') {
+ value = str.toString();
+ map.put(key, value);
+ str = new StringBuffer();
+ i = length;
+ } else {
+ str.append(buf[i]);
+ }
+ break;
+ // case END_OF_LINE :
+ // if (buf[i] == '\n') {
+ // state = END;
+ // break;
+ // } else {
+ // state = BEFORE_SEPERATOR;
+ // str.append(buf[i]);
+ // }
+ // break;
+ // case END:
+ // break;
+ default :
+ throw new AxisFault(
+ "Error Occured Unknown state " + state);
+
+ }
+ }
+
+ state = BEFORE_SEPERATOR;
+
+ }
+ } catch (IOException e) {
+ throw new AxisFault(e.getMessage(), e);
+ }
+ return map;
+ }
+
+ // public HashMap parseTheHeaders(Reader reader, boolean serverSide)
+ // throws AxisFault {
+ // HashMap map = new HashMap();
+ // try {
+ //
+ // StringBuffer str = new StringBuffer();
+ //
+ // int state = BEFORE_SEPERATOR;
+ //
+ // String key = null;
+ // String value = null;
+ //
+ // int start = 0;
+ //
+ // length = readLine(reader,buf);
+ //
+ //
+ //
+ // if (serverSide) {
+ // if (buf[0] == 'P'
+ // && buf[1] == 'O'
+ // && buf[2] == 'S'
+ // && buf[3] == 'T') {
+ // index = 5;
+ // value = readFirstLineArg(' ');
+ // map.put(HTTPConstants.REQUEST_URI,value );
+ // value = readFirstLineArg('\n');
+ // map.put(
+ // HTTPConstants.PROTOCOL_VERSION,value);
+ // start = index;
+ // } else {
+ // throw new AxisFault("Only the POST requests are supported");
+ // }
+ // } else {
+ // index = 0;
+ // value = readFirstLineArg(' ');
+ // map.put(HTTPConstants.PROTOCOL_VERSION, value);
+ // value = readFirstLineArg(' ');
+ // map.put(HTTPConstants.RESPONSE_CODE,value);
+ // value = readFirstLineArg('\n');
+ // map.put(HTTPConstants.RESPONSE_WORD, value);
+ // start = index;
+ // }
+ //
+ // while (state != END) {
+ // if(length <= 0){
+ // throw new AxisFault("Premature end of steam");
+ // }
+ // for (int i = start; i < length; i++) {
+ // System.out.println(state);
+ // switch (state) {
+ // case BEFORE_SEPERATOR :
+ // if (buf[i] == ':') {
+ // key = str.toString();
+ // str = new StringBuffer();
+ // state = AFTER_SEPERATOR;
+ //
+ // if(buf[i+1] == ' '){
+ // i++;//ignore next space
+ // }
+ // } else {
+ // str.append(buf[i]);
+ // }
+ // break;
+ // case AFTER_SEPERATOR :
+ // if (buf[i] == '\n') {
+ // value = str.toString();
+ // map.put(key, value);
+ // str = new StringBuffer();
+ // state = END_OF_LINE;
+ // } else {
+ // str.append(buf[i]);
+ // }
+ // break;
+ // case END_OF_LINE :
+ // if (buf[i] == '\n') {
+ // state = END;
+ // break;
+ // } else {
+ // state = BEFORE_SEPERATOR;
+ // str.append(buf[i]);
+ // }
+ // break;
+ // case END:
+ // break;
+ // default :
+ // throw new AxisFault(
+ // "Error Occured Unknown state " + state);
+ //
+ // }
+ // }
+ // start = 0;
+ // if(state != END){
+ // length = reader.read(buf);
+ // }
+ //
+ //
+ // }
+ // } catch (IOException e) {
+ // throw new AxisFault(e.getMessage(), e);
+ // }
+ // return map;
+ // }
+ private String readFirstLineArg(char terminal) throws AxisFault {
+ StringBuffer str = new StringBuffer();
+ try {
+
+ while (buf[index] != terminal && index < length) {
+ str.append(buf[index]);
+ index++;
+ }
+ index++;
+ return str.toString();
+ } catch (Exception e) {
+ throw new AxisFault(e.getMessage(), e);
+ }
+
+ }
+
+ /**
+ * Read a single line from the input stream
+ *
+ * @param is inputstream to read from
+ * @param b byte array to read into
+ * @param off starting offset into the byte array
+ * @param len maximum number of bytes to read
+ */
+ protected int readLine(Reader is, char[] b) throws java.io.IOException {
+ int count = 0, c;
+
+ // System.out.println("inside here");
+ if (lastRead == -1) {
+ c = is.read();
+ } else {
+ c = lastRead;
+ }
+
+ int off = 0;
+ while (c != -1) {
+ if (c != '\n' && c != '\r') {
+ b[off++] = (char) c;
+ count++;
+ c = is.read();
+ }else{
+ if ('\n' == c) {
+ c = is.read();
+ if(c == '\r'){
+ c = is.read();
+ }
+ //If the next line begins with tab or space then this is a continuation.
+ if (c != ' ' && c != '\t') {
+ if(c == '\n'){
+ done = true;
+ }
+ lastRead = c;
+ b[off++] = '\n';
+ count++;
+ break;
+ }
+
+ }else{
+ c = is.read();
+ }
+ }
+
+
+ }
+ if (c == -1) {
+ throw new AxisFault("Every line should ends with the \n, unexpected End of stream");
+ } else {
+ return count > 0 ? count : -1;
+ }
+
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportSender.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportSender.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/HTTPTransportSender.java Sun Feb 13 20:02:14 2005
@@ -16,22 +16,72 @@
package org.apache.axis.transport.http;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.URL;
+
import org.apache.axis.addressing.EndpointReference;
import org.apache.axis.context.MessageContext;
import org.apache.axis.engine.AxisFault;
import org.apache.axis.transport.AbstractTransportSender;
-import java.io.OutputStream;
-
public class HTTPTransportSender extends AbstractTransportSender {
- protected OutputStream out;
-
- public HTTPTransportSender(OutputStream out) {
- this.out = out;
- }
+ protected Writer out;
+ private Socket socket;
+
+
+ protected Writer obtainOutputStream(MessageContext msgContext)
+ throws AxisFault {
+
+ if (!msgContext.isServerSide()) {
+ EndpointReference toURL = msgContext.getTo();
+
+ if(toURL != null){
+ try {
+ URL url = new URL(toURL.getAddress());
+ SocketAddress add = new InetSocketAddress(url.getHost(),url.getPort());
+ socket = new Socket();
+ socket.connect(add);
+
+ StringBuffer buf = new StringBuffer();
+ buf.append("POST ").append(url.getFile()).append(" HTTP/1.0\n");
+ buf.append("Content-Type: text/xml; charset=utf-8\n");
buf.append("Accept: application/soap+xml, application/dime, multipart/related, text/*\n");
+ buf.append("Host: ").append(url.getHost()).append("\n");
+ buf.append("Cache-Control: no-cache\n");
+ buf.append("Pragma: no-cache\n");
+ buf.append("SOAPAction: \"\"\n\n");
+ outS = socket.getOutputStream();
+ out = new OutputStreamWriter(outS);
+ out.write(buf.toString().toCharArray());
+
+// URLConnection connection = url.openConnection();
+// connection.setDoOutput(true);
+// out = new OutputStreamWriter(connection.getOutputStream());
+
+ msgContext.setProperty(MessageContext.TRANSPORT_READER,new InputStreamReader(socket.getInputStream()));
+ msgContext.setProperty(HTTPConstants.SOCKET,socket);
+ } catch (MalformedURLException e) {
+ throw new AxisFault(e.getMessage(),e);
+ } catch (IOException e) {
+ throw new AxisFault(e.getMessage(),e);
+ }
+
+ }else{
+ throw new AxisFault("to EPR must be specified");
+ }
+
+ }else{
+ out =
+ (Writer) msgContext.getProperty(
+ MessageContext.TRANSPORT_WRITER);
+ }
- protected OutputStream obtainOutputStream(MessageContext msgContext) throws AxisFault {
- OutputStream out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_DATA);
if (out == null) {
throw new AxisFault("can not find the suffient information to find endpoint");
} else {
@@ -40,27 +90,27 @@
}
- protected OutputStream obtainOutputStream(MessageContext msgContext, EndpointReference epr) throws AxisFault {
+ protected Writer obtainOutputStream(
+ MessageContext msgContext,
+ EndpointReference epr)
+ throws AxisFault {
//TODO this is temporay work around
return obtainOutputStream(msgContext);
}
- protected void finalizeSending() {
+ protected void finalizeSending(MessageContext msgContext)throws AxisFault {
}
- protected void startSending() {
-// if(!msgContext.isServerSide()){
-// URL url = (URL)msgContext.getProperty(MessageContext.REQUEST_URL);
-// if(url != null){
-// StringBuffer buf = new StringBuffer();
-// buf.append("POST ").append(url.getFile()).append("HTTP/1.1\n");
-// buf.append("Host: ").append(url.getHost());
-// buf.append("Content-Type: application/soap+xml; charset=\"utf-8\"\n");
-// out.write(buf.toString().getBytes());
-// }else{
-// throw new AxisFault(MessageContext.REQUEST_URL + "where to send ?");
-// }
-// }
+ protected void startSending(MessageContext msgContext)throws AxisFault {
+
+ // Content-Type: text/xml; charset=utf-8
+ // Accept: application/soap+xml, application/dime, multipart/related, text/*
+ // User-Agent: Axis/1.2RC1
+ // Host: 127.0.0.1:8081
+ // Cache-Control: no-cache
+ // Pragma: no-cache
+ // SOAPAction: ""
+
}
}
Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/SimpleHTTPServer.java?view=auto&rev=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/SimpleHTTPServer.java (added)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/java/org/apache/axis/transport/http/SimpleHTTPServer.java Sun Feb 13 20:02:14 2005
@@ -0,0 +1,235 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis.transport.http;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.engine.EngineRegistry;
+import org.apache.axis.engine.EngineRegistryFactory;
+import org.apache.axis.transport.TransportSenderLocator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This is a simple implementation of an HTTP server for processing
+ * SOAP requests via Apache's xml-axis. This is not intended for production
+ * use. Its intended uses are for demos, debugging, and performance
+ * profiling.
+ * <p/>
+ * Note this classes uses static objects to provide a thread pool, so you should
+ * not use multiple instances of this class in the same JVM/classloader unless
+ * you want bad things to happen at shutdown.
+ */
+public class SimpleHTTPServer implements Runnable {
+ protected Log log = LogFactory.getLog(SimpleHTTPServer.class.getName());
+ protected EngineRegistry engineReg;
+ protected ServerSocket serverSocket;
+ protected Socket socket;
+ /**
+ * are we stopped?
+ * latch to true if stop() is called
+ */
+ private boolean stopped = false;
+
+ public SimpleHTTPServer(EngineRegistry reg) {
+ this.engineReg = reg;
+
+ }
+
+ public SimpleHTTPServer(String dir) throws AxisFault {
+ EngineRegistry er = EngineRegistryFactory.createEngineRegistry(dir);
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e1) {
+ throw new AxisFault("Thread interuptted", e1);
+ }
+ this.engineReg = er;
+
+ }
+
+ /**
+ * stop the server if not already told to.
+ *
+ * @throws Throwable
+ */
+ protected void finalize() throws Throwable {
+ stop();
+ super.finalize();
+ }
+
+ /**
+ * Accept requests from a given TCP port and send them through the
+ * Axis engine for processing.
+ */
+ public void run() {
+ try {
+ while (!stopped) {
+ try {
+ // Accept and process requests from the socket
+
+ try {
+ socket = serverSocket.accept();
+ } catch (java.io.InterruptedIOException iie) {
+ } catch (Exception e) {
+ log.debug(e);
+ break;
+ }
+ if (socket != null) {
+ if (engineReg == null) {
+ throw new AxisFault("Engine Must be null");
+ }
+ Writer out =
+ new OutputStreamWriter(socket.getOutputStream());
+ Reader in =
+ new InputStreamReader(socket.getInputStream());
+ MessageContext msgContext =
+ new MessageContext(this.engineReg, null);
+ msgContext.setServerSide(true);
+
+ out.write(HTTPConstants.HTTP);
+ out.write(HTTPConstants.OK);
+ out.write("\n\n".toCharArray());
+ log.info("status written");
+ //We do not have any Addressing Headers to put
+ //let us put the information about incoming transport
+ msgContext.setProperty(
+ MessageContext.TRANSPORT_TYPE,
+ TransportSenderLocator.TRANSPORT_HTTP);
+ msgContext.setProperty(
+ MessageContext.TRANSPORT_WRITER,
+ out);
+ msgContext.setProperty(
+ MessageContext.TRANSPORT_READER,
+ in);
+ HTTPTransportReciver reciver =
+ new HTTPTransportReciver();
+ reciver.invoke(msgContext);
+
+ }
+ } catch (Throwable e) {
+ log.error(e);
+ } finally {
+ if (socket != null) {
+ this.socket.close();
+ this.socket = null;
+ }
+ }
+ }
+
+ } catch (IOException e) {
+ log.error(e);
+ }
+ stop();
+ log.info("Simple Axis Server Quit");
+ }
+
+ /**
+ * Obtain the serverSocket that that SimpleAxisServer is listening on.
+ */
+ public ServerSocket getServerSocket() {
+ return serverSocket;
+ }
+
+ /**
+ * Set the serverSocket this server should listen on.
+ * (note : changing this will not affect a running server, but if you
+ * stop() and then start() the server, the new socket will be used).
+ */
+ public void setServerSocket(ServerSocket serverSocket) {
+ this.serverSocket = serverSocket;
+ }
+
+ /**
+ * Start this server as a NON-daemon.
+ */
+ public void start() throws Exception {
+ run();
+ }
+
+ /**
+ * Stop this server. Can be called safely if the system is already stopped,
+ * or if it was never started.
+ * <p/>
+ * This will interrupt any pending accept().
+ */
+ public void stop() {
+ log.info("stop called");
+ //recognise use before we are live
+ if (stopped) {
+ return;
+ }
+ /*
+ * Close the server socket cleanly, but avoid fresh accepts while
+ * the socket is closing.
+ */
+ stopped = true;
+
+ try {
+ if (serverSocket != null) {
+ serverSocket.close();
+ // while(socket != null){
+ // try {
+ // //make sure all sockets closed by the time
+ // //else we got in to lot of trouble testing
+ // Thread.sleep(1000);
+ // } catch (InterruptedException e1) {
+ // log.error(e1);
+ // }
+ // }
+ }
+ } catch (IOException e) {
+ log.info(e);
+ } finally {
+ serverSocket = null;
+ }
+ log.info("Simple Axis Server Quits");
+ }
+
+ public EngineRegistry getEngineReg() {
+ return engineReg;
+ }
+
+ public static void main(String[] args) throws Exception {
+ if (args.length != 2) {
+ System.out.println("SimpeHttpReciver repositoryLocation port");
+ }
+ SimpleHTTPServer reciver = new SimpleHTTPServer(args[0]);
+
+ ServerSocket serverSoc = null;
+ serverSoc = new ServerSocket(Integer.parseInt(args[1]));
+ reciver.setServerSocket(serverSoc);
+ Thread thread = new Thread(reciver);
+ thread.setDaemon(true);
+
+ try {
+ thread.start();
+ System.in.read();
+ } finally {
+ reciver.stop();
+
+ }
+ }
+
+}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadIncreaseTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadIncreaseTest.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadIncreaseTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadIncreaseTest.java Sun Feb 13 20:02:14 2005
@@ -1,3 +1,7 @@
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
/*
* Created on Feb 9, 2005
*
@@ -11,13 +15,15 @@
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class LoadIncreaseTest {
- public static void main(String[] args) {
- int count = 0;
+ public static void main(String[] args) throws IOException {
+ Writer writer = new FileWriter("results/result.txt");
+ Collecter c = new Collecter(1000,"Load increase test, Axis2",writer);
+ int count = 14000;
while(true) {
count = count + 1000;
System.out.print("Invoke ="+ count + " |");
- Sampler sampler = new Sampler(count);
+ Sampler sampler = new Sampler(count,c);
try {
sampler.invokeService();
} catch (Exception e) {
@@ -26,5 +32,6 @@
break;
}
}
+ c.printResult();
}
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadTest.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadTest.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/LoadTest.java Sun Feb 13 20:02:14 2005
@@ -1,3 +1,7 @@
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
/*
* Created on Feb 9, 2005
*
@@ -12,19 +16,26 @@
*/
public class LoadTest implements Runnable {
private int sizeOfArray = 10;
- private int numberOfRequests = 100;
+ private static int numberOfRequests = 100;
private int no;
-
- public LoadTest(int no){
+ private static int THREAD_COUNT = 500;
+ private Collecter c;
+ public LoadTest(int no,Collecter c){
this.no = no;
+ this.c = c;
}
- public static void main(String[] args) {
- for (int i = 0; i < 100; i++) {
+ public static void main(String[] args) throws IOException {
+ Writer writer = new FileWriter("results/result.txt");
+ Collecter c = new Collecter(THREAD_COUNT * numberOfRequests,"Load increase test, Axis2",writer);
+ for (int i = 0; i < THREAD_COUNT; i++) {
System.out.println("Thread "+i+ " started");
- Thread thread = new Thread(new LoadTest(i));
+ Thread thread = new Thread(new LoadTest(i,c));
thread.start();
}
+ c.printResult();
+ writer.close();
+
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
@@ -34,7 +45,7 @@
for (int i = 0; i < numberOfRequests; i++) {
try {
- Sampler sampler = new Sampler(sizeOfArray);
+ Sampler sampler = new Sampler(sizeOfArray,c);
sampler.invokeService();
} catch (Exception e) {
e.printStackTrace();
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/Sampler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/Sampler.java?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/Sampler.java (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/samples/encoding/sample1/src/Sampler.java Sun Feb 13 20:02:14 2005
@@ -15,25 +15,14 @@
public class Sampler {
private int count;
- public Sampler(int count){
+ private Collecter collector;
+ public Sampler(int count,Collecter collector){
this.count = count;
+ this.collector = collector;
}
public void invokeService() throws Exception {
- long start = System.currentTimeMillis();
- OMFactory fac = OMFactory.newInstance();
- OMNamespace ns =
- fac.createOMNamespace(
- "http://apache.ws.apache.org/samples",
- "samples");
- OMNamespace arrayNs =
- fac.createOMNamespace(
- OMConstants.ARRAY_ITEM_NSURI,
- OMConstants.ARRAY_ITEM_NS_PREFIX);
- OMNamespace targetNs =
- fac.createOMNamespace("http://axis.apache.org", "s");
-
EchoStruct[] objs = new EchoStruct[count];
for (int i = 0; i < objs.length; i++) {
@@ -53,6 +42,20 @@
objs[i].setValue13("English Opening"+i);
}
+ long start = System.currentTimeMillis();
+ OMFactory fac = OMFactory.newInstance();
+ OMNamespace ns =
+ fac.createOMNamespace(
+ "http://apache.ws.apache.org/samples",
+ "samples");
+ OMNamespace arrayNs =
+ fac.createOMNamespace(
+ OMConstants.ARRAY_ITEM_NSURI,
+ OMConstants.ARRAY_ITEM_NS_PREFIX);
+ OMNamespace targetNs =
+ fac.createOMNamespace("http://axis.apache.org", "s");
+
+
OMElement returnelement = fac.createOMElement("param1", ns);
EchoStructEncoder encoder = new EchoStructEncoder();
ArrayTypeEncoder arrayEncoder = new ArrayTypeEncoder(objs, encoder);
@@ -107,8 +110,8 @@
}
}
-
- System.out.println(end -start);
-
+ long val = end -start;
+ System.out.println(val);
+ collector.add(val);
}
}
Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties?view=diff&r1=153706&r2=153707
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties (original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/log4j.properties Sun Feb 13 20:02:14 2005
@@ -1,5 +1,5 @@
-#### Use two appenders, one to log to console, another to log to a file
-log4j.rootCategory=DEBUG, CONSOLE, LOGFILE
+## Use two appenders, one to log to console, another to log to a file
+log4j.rootCategory=ERROR, CONSOLE, LOGFILE
#### appender writes to a file
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
@@ -15,6 +15,6 @@
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=DEBUG
+log4j.appender.CONSOLE.Threshold=ERROR
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n