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/06/29 06:21:57 UTC
svn commit: r202315 - in /webservices/axis/trunk/java/modules: core/
core/src/org/apache/axis/ core/src/org/apache/axis/clientapi/
core/src/org/apache/axis/transport/
core/src/org/apache/axis/transport/http/ samples/
samples/test/org/apache/axis/engine/
Author: hemapani
Date: Tue Jun 28 21:21:55 2005
New Revision: 202315
URL: http://svn.apache.org/viewcvs?rev=202315&view=rev
Log:
checked in the changes to commons transport
Added:
webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/CommonsHTTPTransportSender.java
webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/CommonsHTTPEchoRawXMLTest.java
webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/commons-http-enabled-axis2.xml
Modified:
webservices/axis/trunk/java/modules/core/project.xml
webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java
webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java
webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java
webservices/axis/trunk/java/modules/samples/maven.xml
webservices/axis/trunk/java/modules/samples/project.xml
Modified: webservices/axis/trunk/java/modules/core/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/project.xml?rev=202315&r1=202314&r2=202315&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/project.xml (original)
+++ webservices/axis/trunk/java/modules/core/project.xml Tue Jun 28 21:21:55 2005
@@ -98,6 +98,15 @@
<module>true</module>
</properties>
</dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0-rc2</version>
+ <properties>
+ <module>true</module>
+ </properties>
+ </dependency>
+
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java?rev=202315&r1=202314&r2=202315&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/Constants.java Tue Jun 28 21:21:55 2005
@@ -78,10 +78,9 @@
* Field TRANSPORT_HTTP
*/
public static final String TRANSPORT_HTTP = "http";
-
- /**
- * Field TRANSPORT_SMTP
- */
+
+ public static final String TRANSPORT_COMMONS_HTTP = "commons-http";
+
public static final String TRANSPORT_MAIL = "mail";
public static final String TRANSPORT_JMS = "jms";
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java?rev=202315&r1=202314&r2=202315&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/clientapi/InOutMEPClient.java Tue Jun 28 21:21:55 2005
@@ -191,7 +191,7 @@
engine.send(msgctx);
} else {
serviceContext.getEngineContext().getThreadPool().addWorker(
- new NonBlockingInvocationWorker(callback,axisop,msgctx));
+ new NonBlockingInvocationWorker(callback, axisop, msgctx));
}
// //TODO start the server
@@ -277,22 +277,28 @@
boolean useSeparateListener)
throws AxisFault {
- if (useSeparateListener
- || (senderTransport.equals(listenerTransport)
+ if (useSeparateListener) {
+ if ((senderTransport.equals(listenerTransport)
&& (Constants.TRANSPORT_HTTP.equals(senderTransport)
- || Constants.TRANSPORT_TCP.equals(senderTransport)))) {
+ || Constants.TRANSPORT_TCP.equals(senderTransport)))
+ || (Constants.TRANSPORT_COMMONS_HTTP.equals(senderTransport)
+ && Constants.TRANSPORT_HTTP.equals(listenerTransport))) {
+ this.useSeparateListener = useSeparateListener;
+ } else {
+ throw new AxisFault("useSeparateListener = false is only supports by the htpp transport set as the sender and receiver");
+ }
+ }
- this.useSeparateListener = useSeparateListener;
- } else {
- throw new AxisFault("useSeparateListener = false is only supports by the htpp transport set as the sender and receiver");
+ AxisConfiguration axisConfig = serviceContext.getEngineContext().getAxisConfiguration();
+ this.listenerTransport = axisConfig.getTransportIn(new QName(listenerTransport));
+ this.senderTransport = axisConfig.getTransportOut(new QName(senderTransport));
+ if (this.senderTransport == null) {
+ throw new AxisFault("Unknown transport " + senderTransport);
}
- this.senderTransport =
- serviceContext.getEngineContext().getAxisConfiguration().getTransportOut(
- new QName(senderTransport));
- this.listenerTransport =
- serviceContext.getEngineContext().getAxisConfiguration().getTransportIn(
- new QName(listenerTransport));
+ if (this.listenerTransport == null) {
+ throw new AxisFault("Unknown transport " + listenerTransport);
+ }
if (useSeparateListener == true) {
if (!serviceContext
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java?rev=202315&r1=202314&r2=202315&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/TransportUtils.java Tue Jun 28 21:21:55 2005
@@ -40,6 +40,9 @@
InputStream inStream =
(InputStream) msgContext.getProperty(MessageContext.TRANSPORT_IN);
msgContext.setProperty(MessageContext.TRANSPORT_IN, null);
+ if(inStream == null){
+ throw new AxisFault("Input stram is Null");
+ }
return createSOAPMessage(msgContext, inStream);
}
Added: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/CommonsHTTPTransportSender.java?rev=202315&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/CommonsHTTPTransportSender.java (added)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/CommonsHTTPTransportSender.java Tue Jun 28 21:21:55 2005
@@ -0,0 +1,292 @@
+package org.apache.axis.transport.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.context.ConfigurationContext;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.description.Parameter;
+import org.apache.axis.description.TransportOutDescription;
+import org.apache.axis.engine.AxisFault;
+import org.apache.axis.handlers.AbstractHandler;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMOutput;
+import org.apache.axis.transport.TransportSender;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+
+public class CommonsHTTPTransportSender extends AbstractHandler implements TransportSender {
+ private boolean chuncked = false;
+ private boolean doMTOM = false;
+ private String httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
+ public static final String TRANSPORT_SENDER_INFO = "TRANSPORT_SENDER_INFO";
+
+ protected PostMethod postMethod;
+ protected HttpClient httpClient;
+ protected OMElement outputMessage;
+ protected boolean doREST;
+
+ public CommonsHTTPTransportSender() {
+ } //default
+
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ try {
+ //Check for the REST behaviour, if you desire rest beahaviour
+ //put a <parameter name="doREST" value="true"/> at the server.xml/client.xml file
+ Object doREST = msgContext.getProperty(Constants.Configuration.DO_REST);
+ if (doREST != null && Constants.VALUE_TRUE.equals(doREST)) {
+ this.doREST = true;
+ }
+
+ EndpointReference epr = null;
+ if (msgContext.getTo() != null
+ && !AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(
+ msgContext.getTo().getAddress())
+ && !AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(
+ msgContext.getTo().getAddress())) {
+ epr = msgContext.getTo();
+ }
+
+ OMElement dataOut = null;
+ if (this.doREST) {
+ dataOut = msgContext.getEnvelope().getFirstElement();
+ } else {
+ dataOut = msgContext.getEnvelope();
+ }
+
+ //TODO timeout, configuration
+ if (epr != null) {
+ writeMessageWithCommons(msgContext, epr, dataOut);
+ } else {
+ OutputStream out =
+ (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+ OMOutput output = new OMOutput(out, false);
+ dataOut.serialize(output);
+ }
+ msgContext.getOperationContext().setProperty(
+ Constants.RESPONSE_WRITTEN,
+ Constants.VALUE_TRUE);
+ } catch (XMLStreamException e) {
+ throw new AxisFault(e);
+ } catch (FactoryConfigurationError e) {
+ throw new AxisFault(e);
+ }
+ }
+
+ public void writeMessageWithToOutPutStream(MessageContext msgContext, OutputStream out) {
+
+ }
+
+ public void writeMessageWithCommons(
+ MessageContext msgContext,
+ EndpointReference toURL,
+ OMElement dataout)
+ throws AxisFault {
+ try {
+ URL url = new URL(toURL.getAddress());
+ //Configure the transport
+ String soapAction = msgContext.getWSAAction();
+ //settign soapAction
+ String soapActionString = soapAction == null ? "" : soapAction.toString();
+
+ PostMethod postMethod = new PostMethod();
+ postMethod.setRequestEntity(new AxisRequestEntity(dataout, chuncked));
+ if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10) && chuncked) {
+ ((PostMethod) postMethod).setContentChunked(true);
+ }
+
+ postMethod.setRequestHeader(
+ HTTPConstants.HEADER_CONTENT_TYPE,
+ "text/xml; charset=utf-8");
+ postMethod.setRequestHeader(
+ HTTPConstants.HEADER_ACCEPT,
+ HTTPConstants.HEADER_ACCEPT_APPL_SOAP
+ + HTTPConstants.HEADER_ACCEPT_APPLICATION_DIME
+ + HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED
+ + HTTPConstants.HEADER_ACCEPT_TEXT_ALL);
+ postMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());
+ postMethod.setRequestHeader(HTTPConstants.HEADER_CACHE_CONTROL, "no-cache");
+ postMethod.setRequestHeader(HTTPConstants.HEADER_PRAGMA, "no-cache");
+ //content length is not set yet
+ //setting HTTP vesion
+
+ if (httpVersion != null) {
+ if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
+ //postMethod.setHttp11(false); todo method to findout the transport version...
+ //allowing keep-alive for 1.0
+ postMethod.setRequestHeader(
+ HTTPConstants.HEADER_CONNECTION,
+ HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
+ } else {
+ // allowing keep-alive for 1.1
+ postMethod.setRequestHeader(
+ HTTPConstants.HEADER_CONNECTION,
+ HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
+ }
+ }
+ // othervise assumes HTTP 1.1 and keep-alive is default.
+ if (!this.doREST) {
+ postMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION, soapActionString);
+ }
+
+ //execuite the HtttpMethodBase - a connection manager can be given for handle multiple
+ httpClient = new HttpClient();
+ //hostConfig handles the socket functions..
+ HostConfiguration hostConfig = getHostConfiguration(msgContext, url);
+
+ //code that wirte the stream to the wire
+
+ this.httpClient.executeMethod(hostConfig, this.postMethod);
+ if(postMethod.getStatusCode() == HttpStatus.SC_OK){
+ InputStream in = postMethod.getResponseBodyAsStream();
+ if(in == null){
+ throw new AxisFault("Input Stream can not be Null");
+ }
+ msgContext.getOperationContext().setProperty(MessageContext.TRANSPORT_IN,in);
+ }else if(postMethod.getStatusCode() == HttpStatus.SC_ACCEPTED){
+ return;
+ }else{
+ throw new AxisFault("Error "+ postMethod.getStatusCode() + " Error Message is "+postMethod.getResponseBodyAsString());
+ }
+ } catch (MalformedURLException e) {
+ throw new AxisFault(e);
+ } catch (HttpException e) {
+ throw new AxisFault(e);
+ } catch (IOException e) {
+ throw new AxisFault(e);
+ }
+
+ }
+
+ protected HostConfiguration getHostConfiguration(MessageContext context, URL targetURL) {
+ //TODO cheaking wheather the host is a proxy
+ HostConfiguration config = new HostConfiguration();
+ config.setHost(targetURL.getHost(), targetURL.getPort() == -1 ? 80 : targetURL.getPort());
+ return config;
+ }
+ //get the contentLength...
+ public class AxisRequestEntity implements RequestEntity {
+ private OMElement element;
+ private boolean chuncked;
+ private byte[] bytes;
+
+ public AxisRequestEntity(OMElement element, boolean chuncked) {
+ this.element = element;
+ this.chuncked = chuncked;
+ }
+ public boolean isRepeatable() {
+ return false;
+ }
+
+ public byte[] writeBytes() throws AxisFault {
+ try {
+ ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+ XMLStreamWriter outputWriter =
+ XMLOutputFactory.newInstance().createXMLStreamWriter(bytesOut);
+ OMOutput output = new OMOutput(outputWriter);
+ element.serialize(output);
+ outputWriter.flush();
+ return bytesOut.toByteArray();
+ } catch (XMLStreamException e) {
+ throw new AxisFault(e);
+ } catch (FactoryConfigurationError e) {
+ throw new AxisFault(e);
+ }
+ }
+
+ public void writeRequest(OutputStream out) throws IOException {
+ try {
+ if (chuncked) {
+ XMLStreamWriter outputWriter = null;
+ outputWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+ OMOutput output = new OMOutput(outputWriter);
+ element.serialize(output);
+ outputWriter.flush();
+ out.flush();
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ out.write(bytes);
+ }
+ } catch (XMLStreamException e) {
+ throw new AxisFault(e);
+ } catch (FactoryConfigurationError e) {
+ throw new AxisFault(e);
+ } catch (IOException e) {
+ throw new AxisFault(e);
+ }
+ }
+
+ public long getContentLength() {
+ try {
+ if (chuncked) {
+ return -1;
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ return bytes.length;
+ }
+ } catch (AxisFault e) {
+ return -1;
+ }
+ }
+
+ public String getContentType() {
+ return "text/xml; charset=utf-8";
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.transport.TransportSender#cleanUp(org.apache.axis.context.MessageContext)
+ */
+ public void cleanUp(MessageContext msgContext) throws AxisFault {
+ ((PostMethod) this.postMethod).releaseConnection();
+
+ }
+
+ public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
+ throws AxisFault {
+ //<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.0</parameter> or
+ //<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.1</parameter> is checked
+ Parameter version = transportOut.getParameter(HTTPConstants.PROTOCOL_VERSION);
+ if (version != null) {
+ if (HTTPConstants.HEADER_PROTOCOL_11.equals(version.getValue())) {
+ this.httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
+ Parameter transferEncoding =
+ transportOut.getParameter(HTTPConstants.HEADER_TRANSFER_ENCODING);
+ if (transferEncoding != null
+ && HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(
+ transferEncoding.getValue())) {
+ this.chuncked = true;
+ }
+ } else if (HTTPConstants.HEADER_PROTOCOL_10.equals(version.getValue())) {
+ //TODO HTTP1.0 specific parameters
+ } else {
+ throw new AxisFault(
+ "Parameter "
+ + HTTPConstants.PROTOCOL_VERSION
+ + " Can have values only HTTP/1.0 or HTTP/1.1");
+ }
+ }
+
+ }
+
+}
Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java?rev=202315&r1=202314&r2=202315&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/transport/http/HTTPTransportSender.java Tue Jun 28 21:21:55 2005
@@ -251,13 +251,7 @@
}
- /* (non-Javadoc)
- * @see org.apache.axis.transport.TransportSender#init(org.apache.axis.context.ConfigurationContext, org.apache.axis.description.TransportOutDescription)
- */
- public void init(
- ConfigurationContext confContext,
- TransportOutDescription transportOut)
- throws AxisFault {
+ public void init(ConfigurationContext confContext,TransportOutDescription transportOut) throws AxisFault {
//<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.0</parameter> or
//<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.1</parameter> is checked
Parameter version =
Modified: webservices/axis/trunk/java/modules/samples/maven.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/maven.xml?rev=202315&r1=202314&r2=202315&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/maven.xml (original)
+++ webservices/axis/trunk/java/modules/samples/maven.xml Tue Jun 28 21:21:55 2005
@@ -30,7 +30,10 @@
<copy file="../addressing/target/addressing.mar"
tofile="target/test-resources/mail-transport-enabledRepository/modules/addressing.mar"/>
-
+ <!-- Commons transport enabled enabled Repository -->
+ <mkdir dir="target/test-resources/commons-http-enabledRepository"/>
+ <copy file="test/org/apache/axis/engine/chuncking-enabled-axis2.xml"
+ tofile="target/test-resources/commons-http-enabledRepository/axis2.xml"/>
</postGoal>
<postGoal name="test:test">
Modified: webservices/axis/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/project.xml?rev=202315&r1=202314&r2=202315&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/samples/project.xml (original)
+++ webservices/axis/trunk/java/modules/samples/project.xml Tue Jun 28 21:21:55 2005
@@ -128,6 +128,7 @@
<exclude>**/*MailOneWayRawXMLTest.java</exclude>
<exclude>**/*MailRequestResponseRawXMLTest.java</exclude>
<exclude>**/*EchoRawXMLChunckedTest.java</exclude>
+ <exclude>**/*CommonsHTTPEchoRawXMLTest.java</exclude>
<exclude>**/*EchoRawMTOMTest.java</exclude>
</excludes>
<includes>
Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/CommonsHTTPEchoRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/CommonsHTTPEchoRawXMLTest.java?rev=202315&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/CommonsHTTPEchoRawXMLTest.java (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/CommonsHTTPEchoRawXMLTest.java Tue Jun 28 21:21:55 2005
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2004,2005 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.engine;
+
+//todo
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+
+import junit.framework.TestCase;
+
+import org.apache.axis.Constants;
+import org.apache.axis.addressing.AddressingConstants;
+import org.apache.axis.addressing.EndpointReference;
+import org.apache.axis.clientapi.AsyncResult;
+import org.apache.axis.clientapi.Callback;
+import org.apache.axis.context.MessageContext;
+import org.apache.axis.context.ServiceContext;
+import org.apache.axis.description.ServiceDescription;
+import org.apache.axis.integration.UtilServer;
+import org.apache.axis.om.OMAbstractFactory;
+import org.apache.axis.om.OMElement;
+import org.apache.axis.om.OMFactory;
+import org.apache.axis.om.OMNamespace;
+import org.apache.axis.om.OMOutput;
+import org.apache.axis.soap.SOAPFactory;
+import org.apache.axis.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class CommonsHTTPEchoRawXMLTest extends TestCase {
+ private EndpointReference targetEPR =
+ new EndpointReference(AddressingConstants.WSA_TO,
+ "http://127.0.0.1:"
+ + (UtilServer.TESTING_PORT+1)
+ + "/axis/services/EchoXMLService/echoOMElement");
+ private Log log = LogFactory.getLog(getClass());
+ private QName serviceName = new QName("EchoXMLService");
+ private QName operationName = new QName("echoOMElement");
+
+
+ private AxisConfiguration engineRegistry;
+ private MessageContext mc;
+ //private Thread thisThread;
+ // private SimpleHTTPServer sas;
+ private ServiceContext serviceContext;
+ private ServiceDescription service;
+
+ private boolean finish = false;
+
+ public CommonsHTTPEchoRawXMLTest() {
+ super(CommonsHTTPEchoRawXMLTest.class.getName());
+ }
+
+ public CommonsHTTPEchoRawXMLTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ UtilServer.start();
+ service =
+ Utils.createSimpleService(serviceName,
+ Echo.class.getName(),
+ operationName);
+ UtilServer.deployService(service);
+ serviceContext =
+ UtilServer.getConfigurationContext().createServiceContext(service.getName());
+
+ }
+
+ protected void tearDown() throws Exception {
+ UtilServer.unDeployService(serviceName);
+ UtilServer.stop();
+ }
+
+ private OMElement createEnvelope() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
+ OMElement method = fac.createOMElement("echoOMElement", omNs);
+ OMElement value = fac.createOMElement("myValue", omNs);
+ value.addChild(fac.createText(value, "Isaac Assimov, the foundation Sega"));
+ method.addChild(value);
+
+ return method;
+ }
+
+ public void testEchoXMLASync() throws Exception {
+ OMElement payload = createEnvelope();
+
+ org.apache.axis.clientapi.Call call = new org.apache.axis.clientapi.Call(Constants.TESTING_PATH+"commons-http-enabledRepository");
+
+ call.setTo(targetEPR);
+ call.setTransportInfo(Constants.TRANSPORT_COMMONS_HTTP, Constants.TRANSPORT_HTTP, false);
+
+ Callback callback = new Callback() {
+ public void onComplete(AsyncResult result) {
+ try {
+ result.getResponseEnvelope().serializeWithCache(new OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out)));
+ } catch (XMLStreamException e) {
+ reportError(e);
+ } finally {
+ finish = true;
+ }
+ }
+
+ public void reportError(Exception e) {
+ e.printStackTrace();
+ finish = true;
+ }
+ };
+
+ call.invokeNonBlocking(operationName.getLocalPart(), payload, callback);
+ int index = 0;
+ while (!finish) {
+ Thread.sleep(1000);
+ index++;
+ if(index > 10 ){
+ throw new AxisFault("Server is shutdown as the Async response take too longs time");
+ }
+ }
+ call.close();
+
+
+ log.info("send the reqest");
+ }
+
+ public void testEchoXMLSync() throws Exception {
+ SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
+
+ OMElement payload = createEnvelope();
+
+ org.apache.axis.clientapi.Call call = new org.apache.axis.clientapi.Call(Constants.TESTING_PATH+"commons-http-enabledRepository");
+
+ call.setTo(targetEPR);
+ call.setTransportInfo(Constants.TRANSPORT_COMMONS_HTTP, Constants.TRANSPORT_HTTP, false);
+
+ OMElement result =
+ (OMElement) call.invokeBlocking(operationName.getLocalPart(), payload);
+ result.serializeWithCache(new OMOutput(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out)));
+ call.close();
+ }
+
+}
Added: webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/commons-http-enabled-axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/commons-http-enabled-axis2.xml?rev=202315&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/commons-http-enabled-axis2.xml (added)
+++ webservices/axis/trunk/java/modules/samples/test/org/apache/axis/engine/commons-http-enabled-axis2.xml Tue Jun 28 21:21:55 2005
@@ -0,0 +1,86 @@
+<axisconfig name="AxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="xsd:false">true</parameter>
+ <parameter name="hotupdate" locked="xsd:false">false</parameter>
+ <!-- Uncomment this to enable REST support -->
+<!-- <parameter name="eanbleREST" locked="xsd:false">true</parameter>-->
+
+
+
+ <parameter name="userName" locked="xsd:false">admin</parameter>
+ <parameter name="password" locked="xsd:false">axis2</parameter>
+
+
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!-- This is the Deafult Message Receiver for the Request Response style Operations -->
+ <messageReceiver mep="INOUT" class="org.apache.axis.receivers.RawXMLINOutMessageReceiver"/>
+
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http" class="org.apache.axis.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="xsd:false">6060</parameter>
+ </transportReceiver>
+
+
+
+ <transportReceiver name="tcp" class="org.apache.axis.transport.tcp.TCPServer">
+ <parameter name="port" locked="xsd:false">6060</parameter>
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="http" class="org.apache.axis.transport.http.HTTPTransportSender">
+ <parameter name="PROTOCOL" locked="xsd:false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="xsd:false">chunked</parameter>
+ </transportSender>
+
+ <transportSender name="tcp" class="org.apache.axis.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local" class="org.apache.axis.transport.local.LocalTransportSender"/>
+
+ <transportSender name="commons-http" class="org.apache.axis.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="xsd:false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="xsd:false">chunked</parameter>
+ </transportSender>
+
+
+ <!-- ================================================= -->
+ <!-- Global Modules -->
+ <!-- ================================================= -->
+ <!-- Uncomment this to enable Addressing
+ <module ref="addressing"/> -->
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="TransportIn"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch"/>
+ <phase name="PostDispatch"/>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+</axisconfig>
+