Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 60085 invoked from network); 25 Mar 2007 18:42:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Mar 2007 18:42:01 -0000 Received: (qmail 21233 invoked by uid 500); 25 Mar 2007 18:42:07 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 21172 invoked by uid 500); 25 Mar 2007 18:42:07 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 21161 invoked by uid 500); 25 Mar 2007 18:42:07 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 21158 invoked by uid 99); 25 Mar 2007 18:42:07 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Mar 2007 11:42:07 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Mar 2007 11:41:57 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 4115C1A9838; Sun, 25 Mar 2007 11:41:37 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r522322 [1/3] - in /webservices/axis2/trunk/java/modules: fastinfoset/ fastinfoset/src/ fastinfoset/src/org/ fastinfoset/src/org/apache/ fastinfoset/src/org/apache/axis2/ fastinfoset/src/org/apache/axis2/fastinfoset/ fastinfoset/test-resour... Date: Sun, 25 Mar 2007 18:41:36 -0000 To: axis2-cvs@ws.apache.org From: thilina@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070325184137.4115C1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: thilina Date: Sun Mar 25 11:41:35 2007 New Revision: 522322 URL: http://svn.apache.org/viewvc?view=rev&rev=522322 Log: Applying the patch given at https://issues.apache.org/jira/browse/AXIS2-2372 Thanx Sanjaya for helping us to get in a much awaited feature... Added: webservices/axis2/trunk/java/modules/fastinfoset/ webservices/axis2/trunk/java/modules/fastinfoset/maven.xml webservices/axis2/trunk/java/modules/fastinfoset/pom.xml webservices/axis2/trunk/java/modules/fastinfoset/project.properties webservices/axis2/trunk/java/modules/fastinfoset/project.xml webservices/axis2/trunk/java/modules/fastinfoset/src/ webservices/axis2/trunk/java/modules/fastinfoset/src/org/ webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/ webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/ webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/ webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetBuilder.java webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java webservices/axis2/trunk/java/modules/fastinfoset/test/ webservices/axis2/trunk/java/modules/fastinfoset/test-resources/ webservices/axis2/trunk/java/modules/fastinfoset/test-resources/axis2.xml webservices/axis2/trunk/java/modules/fastinfoset/test/org/ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddService.java webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddServiceClient.java webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/xsd/ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/xsd/SimpleAddServiceCallbackHandler.java webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/xsd/SimpleAddServiceStub.java Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/SchemaGenerator.java Added: webservices/axis2/trunk/java/modules/fastinfoset/maven.xml URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/maven.xml?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/maven.xml (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/maven.xml Sun Mar 25 11:41:35 2007 @@ -0,0 +1,14 @@ + + + + + + + + Added: webservices/axis2/trunk/java/modules/fastinfoset/pom.xml URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/pom.xml?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/pom.xml (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/pom.xml Sun Mar 25 11:41:35 2007 @@ -0,0 +1,192 @@ + + + + 4.0.0 + + org.apache.axis2 + axis2-parent + SNAPSHOT + ../parent/pom.xml + + + axis2-fastinfoset + Apache Axis 2.0 - Fast Infoset + Axis2 Fast Infoset module + + + scm:svn:http://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/fastinfoset + scm:svn:https://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/fastinfoset + http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset + + + + + com.sun.xml.fastinfoset + FastInfoset + ${fastinfoset.version} + jar + + true + + https://maven-repository.dev.java.net/nonav/repository/ + + + stax + stax-api + ${stax.api.version} + + true + + http://dist.codehaus.org/stax/jars/ + + + org.apache.ws.commons.axiom + axiom-api + ${axiom.version} + + + org.apache.ws.commons.axiom + axiom-impl + ${axiom.version} + + + org.apache.axis2 + axis2-kernel + ${pom.currentVersion} + + + org.apache.axis2 + axis2-adb + ${pom.currentVersion} + + + wsdl4j + wsdl4j + ${wsdl4j.version} + + true + + + + javax.activation + activation + ${activation.version} + + true + + + + commons-logging + commons-logging + ${commons.logging.version} + + true + + + + ${stax.impl.groupid} + ${stax.impl.artifactid} + ${stax.impl.version} + + true + + http://dist.codehaus.org/stax/jars/ + + + commons-httpclient + commons-httpclient + ${commons.httpclient.version} + + true + + + + commons-fileupload + commons-fileupload + ${commons.fileupload.version} + + true + + + + org.apache.ws.commons.schema + XmlSchema + ${XmlSchema.version} + + + org.apache.axis2 + axis2-java2wsdl + ${pom.currentVersion} + + + annogen + annogen + ${annogen.version} + + true + + http://dist.codehaus.org/annogen/jars/ + + + httpcomponents-httpcore + jakarta-httpcore + ${jakarta.httpcore.version} + + true + + + + backport-util-concurrent + backport-util-concurrent + ${backport_util_concurrent.version} + + true + + + + commons-codec + commons-codec + ${commons.codec.version} + + true + + + + + + src + test + + + test-resources + + + + + + maven-surefire-plugin + true + + false + + + + + Added: webservices/axis2/trunk/java/modules/fastinfoset/project.properties URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/project.properties?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/project.properties (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/project.properties Sun Mar 25 11:41:35 2007 @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------- +# 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. +# ------------------------------------------------------------------- + +maven.multiproject.type=jar Added: webservices/axis2/trunk/java/modules/fastinfoset/project.xml URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/project.xml?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/project.xml (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/project.xml Sun Mar 25 11:41:35 2007 @@ -0,0 +1,177 @@ + + + + 3 + ../../etc/project.xml + + axis2-fastinfoset + Apache Axis 2.0 - Fast Infoset + org.apache.axis2 + Axis2 Fast Infoset module + + + + com.sun.xml.fastinfoset + FastInfoset + ${fastinfoset.version} + jar + + true + + https://maven-repository.dev.java.net/nonav/repository/ + + + stax + stax-api + ${stax.api.version} + + true + + http://dist.codehaus.org/stax/jars/ + + + org.apache.ws.commons.axiom + axiom-api + ${axiom.version} + + + org.apache.ws.commons.axiom + axiom-impl + ${axiom.version} + + + org.apache.axis2 + axis2-kernel + ${pom.currentVersion} + + + org.apache.axis2 + axis2-adb + ${pom.currentVersion} + + + wsdl4j + wsdl4j + ${wsdl4j.version} + + true + + + + javax.activation + activation + ${activation.version} + + true + + + + commons-logging + commons-logging + ${commons.logging.version} + + true + + + + ${stax.impl.groupid} + ${stax.impl.artifactid} + ${stax.impl.version} + + true + + http://dist.codehaus.org/stax/jars/ + + + commons-httpclient + commons-httpclient + ${commons.httpclient.version} + + true + + + + commons-fileupload + commons-fileupload + ${commons.fileupload.version} + + true + + + + org.apache.ws.commons.schema + XmlSchema + ${XmlSchema.version} + + + org.apache.axis2 + axis2-java2wsdl + ${pom.currentVersion} + + + annogen + annogen + ${annogen.version} + + true + + http://dist.codehaus.org/annogen/jars/ + + + httpcomponents-httpcore + jakarta-httpcore + ${jakarta.httpcore.version} + + true + + + + backport-util-concurrent + backport-util-concurrent + ${backport_util_concurrent.version} + + true + + + + commons-codec + commons-codec + ${commons.codec.version} + + true + + + + + + + + + + src + + **/*.properties + **/*.xml + **/*.xsl + **/*.xsd + + + + + Added: webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetBuilder.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetBuilder.java?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetBuilder.java (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetBuilder.java Sun Mar 25 11:41:35 2007 @@ -0,0 +1,64 @@ +/* + * 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.axis2.fastinfoset; + +import java.io.InputStream; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.impl.builder.StAXBuilder; +import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder; +import org.apache.axis2.AxisFault; +import org.apache.axis2.builder.Builder; +import org.apache.axis2.context.MessageContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.sun.xml.fastinfoset.stax.StAXDocumentParser; + +/** + * + * + */ +public class FastInfosetBuilder implements Builder { + + private Log logger = LogFactory.getLog(FastInfosetBuilder.class); + + /** + * Returns a OMElement handler to the document element of the Fast Infoset message. + * + * @param inputStream InputStream to the message + * @param contentType Content type of the message + * @param messageContext MessageContext to be used + * + * @return OMElement handler to the document element + * + * @see org.apache.axis2.builder.Builder#processDocument(InputStream, String, MessageContext) + */ + public OMElement processDocument(InputStream inputStream, String contentType, + MessageContext messageContext) throws AxisFault { + if (logger.isDebugEnabled()) { + logger.debug("Processing a Document with the content type: " + contentType); + } + XMLStreamReader streamReader = new StAXDocumentParser(inputStream); + //OMXMLParserWrapper builder = new StAXOMBuilder(streamReader); + StAXBuilder builder = new StAXSOAPModelBuilder(streamReader); + //TODO Check whether we need to perform any validations here... + return builder.getDocumentElement(); + } +} Added: webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetMessageFormatter.java Sun Mar 25 11:41:35 2007 @@ -0,0 +1,188 @@ +/* + * 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.axis2.fastinfoset; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Iterator; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMOutputFormat; +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.transport.MessageFormatter; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.sun.xml.fastinfoset.stax.StAXDocumentSerializer; + +public class FastInfosetMessageFormatter implements MessageFormatter { + + private Log logger = LogFactory.getLog(FastInfosetMessageFormatter.class); + + /** + * Plain Fast Infoset message formatter doesn't need to handle SOAP. Hence do nothing. + * + * @see org.apache.axis2.transport.MessageFormatter#formatSOAPAction(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.lang.String) + */ + public String formatSOAPAction(MessageContext messageContext, + OMOutputFormat format, String soapAction) { + + return null; + } + + /** + * Retrieves the raw bytes from the SOAP envelop. + * + * @see org.apache.axis2.transport.MessageFormatter#getBytes(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat) + */ + public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) + throws AxisFault { +// OMElement element = messageContext.getEnvelope().getBody().getFirstElement(); + OMElement element = messageContext.getEnvelope(); + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + + try { + //Creates StAX document serializer which actually implements the XMLStreamWriter + XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream); +// streamWriter.writeStartDocument(); + element.serializeAndConsume(streamWriter); + //TODO Looks like the SOAP envelop doesn't have a end document tag. Find out why? + streamWriter.writeEndDocument(); + + return outStream.toByteArray(); + + } catch (XMLStreamException xmlse) { + logger.error(xmlse.getMessage()); + throw new AxisFault(xmlse.getMessage(), xmlse); + } + } + + /** + * Returns the content type + * + * @see org.apache.axis2.transport.MessageFormatter#getContentType(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.lang.String) + */ + public String getContentType(MessageContext messageContext, + OMOutputFormat format, String soapAction) { + String contentType = (String) messageContext.getProperty(Constants.Configuration.CONTENT_TYPE); + String encoding = format.getCharSetEncoding(); + + //FIXME Is this a right thing to do? Need to clarify with a vetarant + if (contentType == null) { + contentType = (String) messageContext.getProperty(Constants.Configuration.MESSAGE_TYPE); + } + + if (encoding != null) { + contentType += "; charset=" + encoding; + } + + return contentType; + } + + /** + * Returns the target address to send the response + * FIXME This is very HTTP specific. What about other transport? + * + * @see org.apache.axis2.transport.MessageFormatter#getTargetAddress(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.net.URL) + */ + public URL getTargetAddress(MessageContext messageContext, + OMOutputFormat format, URL targetURL) throws AxisFault { + String httpMethod = + (String) messageContext.getProperty(Constants.Configuration.HTTP_METHOD); + + URL targetAddress = targetURL; //Let's initialize to this + //if the http method is GET, parameters are attached to the target URL + if ((httpMethod != null) + && Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) { + String param = getParam(messageContext); + + if (param.length() > 0) { + String returnURLFile = targetURL.getFile() + "?" + param; + try { + targetAddress = + new URL(targetURL.getProtocol(), targetURL.getHost(), targetURL.getPort(), returnURLFile); + } catch (MalformedURLException murle) { + logger.error(murle.getMessage()); + throw new AxisFault(murle.getMessage(), murle); + } + } + } + + return targetAddress; + } + + /** + * Write the SOAP envelop to the given OutputStream. + * + * @see org.apache.axis2.transport.MessageFormatter#writeTo(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.io.OutputStream, boolean) + */ + public void writeTo(MessageContext messageContext, OMOutputFormat format, + OutputStream outputStream, boolean preserve) throws AxisFault { + + //OMElement element = messageContext.getEnvelope().getBody().getFirstElement(); + OMElement element = messageContext.getEnvelope(); + + try { + //Create the StAX document serializer + XMLStreamWriter streamWriter = new StAXDocumentSerializer(outputStream); +// streamWriter.writeStartDocument(); + if (preserve) { + element.serialize(streamWriter); + } else { + element.serializeAndConsume(streamWriter); + } +// TODO Looks like the SOAP envelop doesn't have a end document tag. Find out why? + streamWriter.writeEndDocument(); + } catch (XMLStreamException xmlse) { + logger.error(xmlse.getMessage()); + throw new AxisFault(xmlse.getMessage(), xmlse); + } + } + + /** + * Construct URL parameters like, "param1=value1¶m2=value2" + * FIXME This is very HTTP specific. What about other transports + * + * @param messageContext + * @return Formatted URL parameters + */ + private String getParam(MessageContext messageContext) { + + OMElement dataOut = messageContext.getEnvelope().getBody().getFirstElement(); + Iterator it = dataOut.getChildElements(); + StringBuffer paramBuffer = new StringBuffer(); + + while (it.hasNext()) { + OMElement element = (OMElement) it.next(); + String parameter = element.getLocalName() + "=" + element.getText(); + paramBuffer.append(parameter); + paramBuffer.append("&"); + } + //We don't need a '&' at the end + paramBuffer.deleteCharAt(paramBuffer.length() - 1); + + return paramBuffer.toString(); + } + +} Added: webservices/axis2/trunk/java/modules/fastinfoset/test-resources/axis2.xml URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/test-resources/axis2.xml?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/test-resources/axis2.xml (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/test-resources/axis2.xml Sun Mar 25 11:41:35 2007 @@ -0,0 +1,369 @@ + + + + + + + true + false + false + false + + + + + + 30000 + + + + false + + + + + + false + + admin + axis2 + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 8080 + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + HTTP/1.1 + chunked + + + + + + + HTTP/1.1 + chunked + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java Sun Mar 25 11:41:35 2007 @@ -0,0 +1,111 @@ +package org.apache.axis2.fastinfoset; + +import java.io.File; +import java.io.IOException; +import java.net.ServerSocket; +import java.net.SocketException; +import java.rmi.RemoteException; + +import junit.framework.TestCase; + +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.rpc.receivers.RPCMessageReceiver; +import org.apache.axis2.transport.http.SimpleHTTPServer; + +public class FastInfosetTest extends TestCase { + + private SimpleHTTPServer server; + private static int serverCount = 0; + + private AxisService service; + + private EndpointReference target; + private ConfigurationContext configurationContext; + + protected void setUp() throws Exception { + super.setUp(); + + System.out.println("Setting up the Simple HTTP Server"); + + if (serverCount == 0) { + int port = findAvailablePort(); +// port = 8080; //Uncomment to test with tcpmon + target = new EndpointReference("http://127.0.0.1:" + (port) + + "/axis2/services/SimpleAddService"); + + File configFile = new File(System.getProperty("basedir",".") + "/test-resources/axis2.xml"); + configurationContext = ConfigurationContextFactory + .createConfigurationContextFromFileSystem("target/test-classes", configFile + .getAbsolutePath()); + + server = new SimpleHTTPServer(configurationContext, port); + + server.start(); + } + + serverCount++; + + service = AxisService.createService("org.apache.axis2.fastinfoset.SimpleAddService", + server.getConfigurationContext().getAxisConfiguration(), RPCMessageReceiver.class); + + server.getConfigurationContext().getAxisConfiguration().addService( + service); + + System.out.println("Simple HTTP Server is started"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + if(serverCount == 1) { + server.stop(); + System.out.println("Stopped the Simple HTTP Server"); + } + } + + public void testAdd() throws RemoteException { + SimpleAddServiceClient client = new SimpleAddServiceClient(target); //Comment to test with tcpmon. +// SimpleAddServiceClient client = new SimpleAddServiceClient(); //Uncomment to test with tcpmon. + + String result = client.addStrings("Hello ", "World!"); + System.out.println("Output: " + result); + TestCase.assertEquals("Hello World!", result); + + int result1 = client.addInts(17, 33); + System.out.println("Output: " + result1); + TestCase.assertEquals(50, result1); + + float result2 = client.addFloats(17.64f, 32.36f); + System.out.println("Output: " + result2); + TestCase.assertEquals(50.0f, result2, 0.0005f); + } + + private int findAvailablePort() throws SocketException, IOException { + //Create a server socket on any free socket to find a free socket. + ServerSocket ss = new ServerSocket(0); + int port = ss.getLocalPort(); + ss.close(); + + return port; + } + + /** + * Run this class as a Java application, will host this SimpleAddService for further testing. + * There is a main method in SimpleAddServiceClient which can be used with this. + * + * Note: Useful when debugging. + * + * @param args - Not required. + */ + public static void main(String args[]) { + FastInfosetTest test = new FastInfosetTest(); + try { + test.setUp(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} Added: webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddService.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddService.java?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddService.java (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddService.java Sun Mar 25 11:41:35 2007 @@ -0,0 +1,19 @@ +package org.apache.axis2.fastinfoset; + +public class SimpleAddService { + + public int addInts(int val1, int val2) { + System.out.println("Received " + val1 + " & " + val2); + return val1 + val2; + } + + public float addFloats(float val1, float val2) { + System.out.println("Received " + val1 + " & " + val2); + return val1 + val2; + } + + public String addStrings(String val1, String val2) { + System.out.println("Received " + val1 + " & " + val2); + return val1 + val2; + } +} Added: webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddServiceClient.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddServiceClient.java?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddServiceClient.java (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddServiceClient.java Sun Mar 25 11:41:35 2007 @@ -0,0 +1,106 @@ +/* + * 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.axis2.fastinfoset; + +import java.rmi.RemoteException; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub; +import org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddFloats; +import org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddFloatsResponse; +import org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddInts; +import org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddIntsResponse; +import org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddStrings; +import org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddStringsResponse; +import org.apache.axis2.transport.http.HTTPConstants; + +public class SimpleAddServiceClient { + + private SimpleAddServiceStub serviceStub; + + /** + * @param args + */ + public static void main(String[] args) { + try { + SimpleAddServiceClient client = new SimpleAddServiceClient(); + System.out.println("Response 1 is " + client.addStrings("Hello ", "World!")); + System.out.println("Response 2 is " + client.addInts(23, 27)); + System.out.println("Response 3 is " + client.addFloats(22.84f, 27.16f)); + } catch (AxisFault af) { + af.printStackTrace(); + } catch (RemoteException re) { + re.printStackTrace(); + } + } + + /** + * Contructor which uses "http://localhost:8081/axis2/services/SimpleAddService" as the target. + * When the serrver runs at port 8080, this can be use with tcpmon for debugging. + * + * @throws AxisFault + */ + public SimpleAddServiceClient() throws AxisFault { + this(new EndpointReference("http://localhost:8081/axis2/services/SimpleAddService")); + } + + /** + * Constructor used by the default JUnit test case. + * + * @param target + * @throws AxisFault + */ + public SimpleAddServiceClient(EndpointReference target) throws AxisFault { + ConfigurationContext context = + ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-classes", "test-resources/axis2.xml"); + serviceStub = new SimpleAddServiceStub(context, target.getAddress()); + //serviceStub = new SimpleAddServiceStub(); + ServiceClient client= serviceStub._getServiceClient(); + Options options = client.getOptions(); + options.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/soap+fastinfoset"); + } + + public String addStrings(String param0, String param1) throws RemoteException { + AddStrings addStrings = new SimpleAddServiceStub.AddStrings(); + addStrings.setVal1(param0); + addStrings.setVal2(param1); + AddStringsResponse response1 = serviceStub.addStrings(addStrings); + return response1.get_return(); + } + + public int addInts(int param0, int param1) throws RemoteException { + AddInts addInts = new SimpleAddServiceStub.AddInts(); + addInts.setVal1(param0); + addInts.setVal2(param1); + AddIntsResponse response2 = serviceStub.addInts(addInts); + return response2.get_return(); + } + + public float addFloats(float param0, float param1) throws RemoteException { + AddFloats addFloats = new SimpleAddServiceStub.AddFloats(); + addFloats.setVal1(param0); + addFloats.setVal2(param1); + AddFloatsResponse response3 = serviceStub.addFloats(addFloats); + return response3.get_return(); + } +} Added: webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/xsd/SimpleAddServiceCallbackHandler.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/xsd/SimpleAddServiceCallbackHandler.java?view=auto&rev=522322 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/xsd/SimpleAddServiceCallbackHandler.java (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/xsd/SimpleAddServiceCallbackHandler.java Sun Mar 25 11:41:35 2007 @@ -0,0 +1,97 @@ + + /** + * SimpleAddServiceCallbackHandler.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: SNAPSHOT Mar 08, 2007 (04:12:48 LKT) + */ + package org.apache.axis2.fastinfoset.xsd; + + /** + * SimpleAddServiceCallbackHandler Callback class, Users can extend this class and implement + * their own receiveResult and receiveError methods. + */ + public abstract class SimpleAddServiceCallbackHandler{ + + + + protected Object clientData; + + /** + * User can pass in any object that needs to be accessed once the NonBlocking + * Web service call is finished and appropriate method of this CallBack is called. + * @param clientData Object mechanism by which the user can pass in user data + * that will be avilable at the time this callback is called. + */ + public SimpleAddServiceCallbackHandler(Object clientData){ + this.clientData = clientData; + } + + /** + * Please use this constructor if you don't want to set any clientData + */ + public SimpleAddServiceCallbackHandler(){ + this.clientData = null; + } + + /** + * Get the client data + */ + + public Object getClientData() { + return clientData; + } + + + /** + * auto generated Axis2 call back method for addStrings method + * override this method for handling normal response from addStrings operation + */ + public void receiveResultaddStrings( + org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddStringsResponse result + ) { + } + + /** + * auto generated Axis2 Error handler + * override this method for handling error response from addStrings operation + */ + public void receiveErroraddStrings(java.lang.Exception e) { + } + + /** + * auto generated Axis2 call back method for addFloats method + * override this method for handling normal response from addFloats operation + */ + public void receiveResultaddFloats( + org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddFloatsResponse result + ) { + } + + /** + * auto generated Axis2 Error handler + * override this method for handling error response from addFloats operation + */ + public void receiveErroraddFloats(java.lang.Exception e) { + } + + /** + * auto generated Axis2 call back method for addInts method + * override this method for handling normal response from addInts operation + */ + public void receiveResultaddInts( + org.apache.axis2.fastinfoset.xsd.SimpleAddServiceStub.AddIntsResponse result + ) { + } + + /** + * auto generated Axis2 Error handler + * override this method for handling error response from addInts operation + */ + public void receiveErroraddInts(java.lang.Exception e) { + } + + + + } + \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org