Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 5997 invoked from network); 5 Jul 2007 07:07:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jul 2007 07:07:10 -0000 Received: (qmail 91975 invoked by uid 500); 5 Jul 2007 07:07:07 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 91876 invoked by uid 500); 5 Jul 2007 07:07: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 91856 invoked by uid 500); 5 Jul 2007 07:07:07 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 91851 invoked by uid 99); 5 Jul 2007 07:07:07 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jul 2007 00:07: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; Thu, 05 Jul 2007 00:07:03 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 69C8C1A981D; Thu, 5 Jul 2007 00:06:43 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r553397 - in /webservices/axis2/trunk/java/modules/fastinfoset: ./ src/org/apache/axis2/fastinfoset/ test-resources/ test/org/apache/axis2/fastinfoset/ test/org/apache/axis2/fastinfoset/xsd/ Date: Thu, 05 Jul 2007 07:06:43 -0000 To: axis2-cvs@ws.apache.org From: deepal@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070705070643.69C8C1A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: deepal Date: Thu Jul 5 00:06:42 2007 New Revision: 553397 URL: http://svn.apache.org/viewvc?view=rev&rev=553397 Log: applying the patches in AXIS2-2689 - Thx Sanjaya for sending the patches - I have still commented the test case but once Axiom fixed WSCOMMONS-213 Added: webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXBuilder.java webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXMessageFormatter.java Removed: webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/xsd/ Modified: webservices/axis2/trunk/java/modules/fastinfoset/maven.xml webservices/axis2/trunk/java/modules/fastinfoset/project.xml webservices/axis2/trunk/java/modules/fastinfoset/test-resources/axis2.xml webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddServiceClient.java Modified: webservices/axis2/trunk/java/modules/fastinfoset/maven.xml URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/maven.xml?view=diff&rev=553397&r1=553396&r2=553397 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/maven.xml (original) +++ webservices/axis2/trunk/java/modules/fastinfoset/maven.xml Thu Jul 5 00:06:42 2007 @@ -1,41 +1,64 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: webservices/axis2/trunk/java/modules/fastinfoset/project.xml URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/project.xml?view=diff&rev=553397&r1=553396&r2=553397 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/project.xml (original) +++ webservices/axis2/trunk/java/modules/fastinfoset/project.xml Thu Jul 5 00:06:42 2007 @@ -64,7 +64,7 @@ http://dist.codehaus.org/stax/jars/ - + org.apache.ws.commons.axiom axiom-api ${axiom.version} @@ -176,6 +176,41 @@ true + + org.apache.axis2 + axis2-java2wsdl + ${pom.currentVersion} + jar + + true + + + + org.apache.neethi + neethi + ${neethi.version} + + true + + + + org.apache.axis2 + axis2-codegen + ${pom.currentVersion} + jar + + true + + + + org.apache.axis2 + axis2-adb-codegen + ${pom.currentVersion} + jar + + true + + Added: webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXBuilder.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXBuilder.java?view=auto&rev=553397 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXBuilder.java (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXBuilder.java Thu Jul 5 00:06:42 2007 @@ -0,0 +1,69 @@ +/* + * 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.OMNode; +import org.apache.axiom.om.impl.builder.StAXBuilder; +import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.impl.llom.OMNodeImpl; +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; + +/** + * @author Sanjaya Karunasena + * @date May 19, 2007 + */ + +public class FastInfosetPOXBuilder 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); + StAXBuilder builder = new StAXOMBuilder(streamReader); + //TODO Check whether we need to perform any validations here... + OMElement element = builder.getDocumentElement(); +// element = (OMElement) element.detach(); +// ((OMNodeImpl) element).setParent(null); + return element; + } +} Added: webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXMessageFormatter.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXMessageFormatter.java?view=auto&rev=553397 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXMessageFormatter.java (added) +++ webservices/axis2/trunk/java/modules/fastinfoset/src/org/apache/axis2/fastinfoset/FastInfosetPOXMessageFormatter.java Thu Jul 5 00:06:42 2007 @@ -0,0 +1,170 @@ +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 FastInfosetPOXMessageFormatter 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(); + 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(); + } +} Modified: 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=diff&rev=553397&r1=553396&r2=553397 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/test-resources/axis2.xml (original) +++ webservices/axis2/trunk/java/modules/fastinfoset/test-resources/axis2.xml Thu Jul 5 00:06:42 2007 @@ -107,6 +107,8 @@ class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/> + @@ -123,6 +125,8 @@ class="org.apache.axis2.builder.XFormURLEncodedBuilder"/> + Modified: 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=diff&rev=553397&r1=553396&r2=553397 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java (original) +++ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/FastInfosetTest.java Thu Jul 5 00:06:42 2007 @@ -31,7 +31,6 @@ 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; /** @@ -55,7 +54,7 @@ if (serverCount == 0) { int port = findAvailablePort(); -// port = 8080; //Uncomment to test with tcpmon + port = 8080; //Uncomment to test with tcpmon target = new EndpointReference("http://127.0.0.1:" + (port) + "/axis2/services/SimpleAddService"); @@ -73,7 +72,7 @@ service = AxisService.createService("org.apache.axis2.fastinfoset.SimpleAddService", server.getConfigurationContext().getAxisConfiguration()); - + server.getConfigurationContext().getAxisConfiguration().addService( service); @@ -84,6 +83,7 @@ super.tearDown(); if(serverCount == 1) { server.stop(); + serverCount = 0; System.out.println("Stopped the Simple HTTP Server"); } } @@ -103,6 +103,24 @@ float result2 = client.addFloats(17.64f, 32.36f); System.out.println("Output: " + result2); TestCase.assertEquals(50.0f, result2, 0.0005f); + } + + + public void testAdd2() throws RemoteException { +// SimpleAddServiceClient client = new SimpleAddServiceClient(target, true); //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 { Modified: 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=diff&rev=553397&r1=553396&r2=553397 ============================================================================== --- webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddServiceClient.java (original) +++ webservices/axis2/trunk/java/modules/fastinfoset/test/org/apache/axis2/fastinfoset/SimpleAddServiceClient.java Thu Jul 5 00:06:42 2007 @@ -28,13 +28,13 @@ 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.fastinfoset.SimpleAddServiceStub; +import org.apache.axis2.fastinfoset.SimpleAddServiceStub.AddFloats; +import org.apache.axis2.fastinfoset.SimpleAddServiceStub.AddFloatsResponse; +import org.apache.axis2.fastinfoset.SimpleAddServiceStub.AddInts; +import org.apache.axis2.fastinfoset.SimpleAddServiceStub.AddIntsResponse; +import org.apache.axis2.fastinfoset.SimpleAddServiceStub.AddStrings; +import org.apache.axis2.fastinfoset.SimpleAddServiceStub.AddStringsResponse; /** * @author Sanjaya Karunasena (sanjayak@yahoo.com) @@ -86,6 +86,26 @@ options.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/soap+fastinfoset"); } + /** + * Constructor used by the default JUnit test case. + * + * @param target + * @throws AxisFault + */ + public SimpleAddServiceClient(EndpointReference target, boolean pox) 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(); + if (pox) { + options.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/fastinfoset"); + } else { + 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); --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org