commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/soap example.jelly
Date Thu, 10 Oct 2002 22:19:20 GMT
jstrachan    2002/10/10 15:19:19

  Modified:    jelly/src/java/org/apache/commons/jelly jelly.properties
               jelly    maven.xml project.xml
  Added:       jelly/src/java/org/apache/commons/jelly/tags/soap
                        package.html SoapTagLibrary.java InvokeTag.java
               jelly/src/test/org/apache/commons/jelly/soap example.jelly
  Log:
  Added SOAP support via Apache Axis.
  
  This is based on a patch submitted by Jim Birchfield which allows SOAP services to be invoked
using Apache Axis and the results output.
  
  Its early days and we'll improve this support considerably over time but at least the basics
are working for now.
  
  There's a demo invokable via
  
    maven demo:soap
  
  which invokes a sample Axis echo service and an xmethods.net service.
  
  Revision  Changes    Path
  1.25      +1 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties
  
  Index: jelly.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- jelly.properties	10 Oct 2002 09:27:51 -0000	1.24
  +++ jelly.properties	10 Oct 2002 22:19:18 -0000	1.25
  @@ -14,6 +14,7 @@
   
   # optional taglibs
   swing	    = org.apache.commons.jelly.tags.swing.SwingTagLibrary
  +soap		= org.apache.commons.jelly.tags.soap.SoapTagLibrary
   html		= org.apache.commons.jelly.tags.html.HTMLTagLibrary
   betwixt		= org.apache.commons.jelly.tags.betwixt.BetwixtTagLibrary
   jms         = org.apache.commons.jelly.tags.jms.JMSTagLibrary
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/soap/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
    <p>
    	Tags for invoking Web Services via <a href="http://xml.apache.org/axis/">Apache
Axis</a>
    </p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/soap/SoapTagLibrary.java
  
  Index: SoapTagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvspublic/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/util/UtilTagLibrary.java,v
1.1 2002/07/16 05:43:32 werken Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/16 05:43:32 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: SoapTagLibrary.java,v 1.1 2002/07/16 05:43:32 moatas Exp $
   */
  package org.apache.commons.jelly.tags.soap;
  
  import org.apache.commons.jelly.TagLibrary;
  import org.apache.commons.jelly.tags.util.TokenizeTag;
  
  /** Implements general utility tags.
   *
   *  @author <a href="mailto:jim@bnainc.net">jim birchfield</a>
   *  @version $Revision: 1.1 $
   */
  public class SoapTagLibrary extends TagLibrary
  {
      public SoapTagLibrary() {
          registerTag("invoke", InvokeTag.class);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/soap/InvokeTag.java
  
  Index: InvokeTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/InfoTag.java,v
1.6 2002/05/17 15:18:08 jstrachan Exp $
   * $Revision: 1.6 $
   * $Date: 2002/05/17 15:18:08 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: SoapTag.java,v 1.6 2002/05/17 15:18:08 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.soap;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  
  import org.apache.commons.logging.Log;
  import org.apache.axis.client.Service;
  import org.apache.axis.client.Call;
  
  import javax.xml.namespace.QName;
  
  /**
   * Invokes a web service
   * 
   * @author <a href="mailto:jim@bnainc.net">James Birchfield</a>
   * @version $Revision: 1.0 $
   */
  public class InvokeTag extends TagSupport {
  
      private String var;
      private String endpoint = null;
      private String namespace = null;
      private String method = null;
      private Service service;
      
      public InvokeTag() {
      }
  
      // Tag interface
      //-------------------------------------------------------------------------
      public void doTag(XMLOutput output) throws Exception {
          if (endpoint == null) {
              throw new MissingAttributeException("endpoint");
          }
          if (namespace == null) {
              throw new MissingAttributeException("namespace");
          }
          if (method == null) {
              throw new MissingAttributeException("method");
          }
          Service service = getService();
          if (service == null) {
              service = createService();
          }
          Call call = (Call) service.createCall();
  
          // @todo Jelly should have native support for URL and QName
          // directly on properties
          call.setTargetEndpointAddress(new java.net.URL(endpoint));
          call.setOperationName(new QName(namespace, method));
  
          Object ret = call.invoke(new Object[]{getBodyText()});
          
          if (var != null) {
              context.setVariable(var, ret);
          }
          else {
              // should turn the answer into XML events...
              throw new JellyException( "Not implemented yet; should stream results as XML
events. Results: " + ret );
          }
      }
  
  
      // Properties
      //-------------------------------------------------------------------------
      /**
       * Sets the end point to which the invocation will occur
       */
      public void setEndpoint(String endpoint) {
          this.endpoint = endpoint;
      }
  
      /**
       * Sets the namespace of the operation
       */
      public void setNamespace(String namespace) {
          this.namespace = namespace;
      }
  
      public void setMethod(String method) {
          this.method = method;
      }
      
      /**
       * Returns the service to be used by this web service invocation.
       * @return Service
       */
      public Service getService() {
          return service;
      }
  
      /**
       * Sets the service to be used by this invocation.
       * If none is specified then a default is used.
       */
      public void setService(Service service) {
          this.service = service;
      }
  
      /**
       * Sets the name of the variable to output the results of the SOAP call to.
       */
      public void setVar(String var) {
          this.var = var;
      }
  
  
      // Implementation methods
      //-------------------------------------------------------------------------
  
      /**
       * Factory method to create a new default Service instance
       */
      protected Service createService() {
          return new Service();
      }
  }
  
  
  
  1.40      +15 -5     jakarta-commons-sandbox/jelly/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/maven.xml,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- maven.xml	10 Oct 2002 10:24:32 -0000	1.39
  +++ maven.xml	10 Oct 2002 22:19:18 -0000	1.40
  @@ -181,21 +181,21 @@
   
     	
     <goal name="demo:quartz" prereqs="jelly-task" 
  -	description="Runs the example quartz demo">
  +		description="Runs the example quartz demo">
       <java classname="org.apache.commons.jelly.Jelly" fork="yes">
         <classpath refid="test.classpath"/>
         <arg value="src/test/org/apache/commons/jelly/quartz/example.jelly"/> 
       </java>
     </goal>
   
  -  <goal name="demo:soap" prereqs="jelly-task" 
  -	description="Runs the example SOAP demo">
  +  <goal name="demo:soapmacro" prereqs="jelly-task" 
  +		description="Runs a sample SOAP macro">
   	
  -	<jelly file="src/test/org/apache/commons/jelly/define/example.jelly"/> 
  +		<jelly file="src/test/org/apache/commons/jelly/define/example.jelly"/> 
     </goal>
   
     <goal name="demo:bean" prereqs="jelly-task" 
  -	description="Runs the example of binding beans to tags">
  +		description="Runs the example of binding beans to tags">
   
   <!--	
   	<jelly file="src/test/org/apache/commons/jelly/define/beanSample.jelly"/> 
  @@ -516,5 +516,15 @@
     	description="A private target invoked by the async demo">
       <echo>YYYY</echo>
     </goal>
  +
  +
  +  <goal name="demo:soap" prereqs="jelly-task" 
  +		description="Runs a sample using Apache Axis to invoke a web service from inside Jelly">
  +    <java classname="org.apache.commons.jelly.Jelly" fork="yes">
  +      <classpath refid="test.classpath"/>
  +      <arg value="src/test/org/apache/commons/jelly/soap/example.jelly"/> 
  +    </java>
  +  </goal>
  +
   
   </project>
  
  
  
  1.80      +19 -0     jakarta-commons-sandbox/jelly/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- project.xml	10 Oct 2002 13:19:40 -0000	1.79
  +++ project.xml	10 Oct 2002 22:19:19 -0000	1.80
  @@ -407,6 +407,25 @@
         <version>1.2</version>
       </dependency>
   
  +	<!-- soap taglib -->
  +    <dependency>
  +      <id>axis</id>
  +      <version>1.0</version>
  +    </dependency>
  +    <dependency>
  +      <id>jaxrpc</id>
  +      <version>1.0</version>
  +    </dependency>
  +    <dependency>
  +      <id>saaj</id>
  +      <version>1.1</version>
  +    </dependency>
  +<!--    
  +    <dependency>
  +      <id>wsdl4j</id>
  +      <version>1.0</version>
  +    </dependency>
  +-->    
     </dependencies>
     <build>
       <nagEmailAddress>commons-dev@jakarta.apache.org</nagEmailAddress>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/soap/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <j:jelly
    xmlns:soap="jelly:soap"
    xmlns:log="jelly:log"
    xmlns:j="jelly:core">
  
    <soap:invoke
    	var="answer"
      endpoint="http://nagoya.apache.org:5049/axis/services/echo"
      namespace="http://soapinterop.org/"
      method="echoString">Hi Jim!</soap:invoke>
  
    <log:info>Sent: Hi Jim! and received: ${answer} of type: ${answer.class.name}</log:info>
  
    <soap:invoke
    	var="answer"
        endpoint="http://services.xmethods.net:80/soap/servlet/rpcrouter"
        namespace="urn:xmethods-Temperature"
        method="getTemp">40031</soap:invoke>
        
    <log:info>Sent: 40031 and received: ${answer} of type: ${answer.class.name}</log:info>
  </j:jelly>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message