dion        2003/01/07 06:10:03

  Added:       jelly/jelly-tags/soap .cvsignore project.xml maven.xml
                        project.properties
               jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap
                        package.html InvokeTag.java SoapTagLibrary.java
               jelly/jelly-tags/soap/src/test/org/apache/commons/jelly/tags/soap
                        example.jelly
  Log:
  Move soap taglib out of core
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/soap/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  maven.log
  target
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/soap/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE project [
    <!-- see file for description -->
    <!ENTITY commonDeps SYSTEM "file:../../commonDependencies.ent">
  ]>
  <project>
    <extend>../tag-project.xml</extend>
    <id>commons-jelly-tags-soap</id>
    <name>commons-jelly-tags-soap</name>
    <package>org.apache.commons.jelly.tags.soap</package>
  
    <description>
        This is a Jelly interface for SOAP.
    </description>
    <shortDescription>Commons Jelly SOAP Tag Library</shortDescription>
    
    
<siteDirectory>/www/jakarta.apache.org/commons/sandbox/jelly/tags/soap</siteDirectory>
    
<distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jelly/tags/soap</distributionDirectory>
    <repository>
      
<connection>scm:cvs:pserver:[EMAIL PROTECTED]:/home/cvspublic:jakarta-commons-sandbox/jelly/jelly-tags/soap/</connection>
      
<url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/jelly-tags/soap/</url>
    </repository>
    
      
    <dependencies>
    
      &commonDeps;
    
      <!-- START for compilation -->
    
      <dependency>
        <id>commons-jelly</id>
        <version>SNAPSHOT</version>
      </dependency>
      
      <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>
    
    </dependencies>
    
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/soap/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="java:jar">
  
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/jelly-tags/soap/project.properties
  
  Index: project.properties
  ===================================================================
  # -------------------------------------------------------------------
  # P R O J E C T  P R O P E R T I E S
  # -------------------------------------------------------------------
  
  maven.junit.fork=true
  
  maven.compile.deprecation = on
  
  # Installation dir
  maven.dist.install.dir = /usr/local/jelly
  
  maven.checkstyle.properties=../tag-checkstyle.properties
  
  
  1.1                  
jakarta-commons-sandbox/jelly/jelly-tags/soap/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/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/InvokeTag.java
  
  Index: InvokeTag.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/InvokeTag.java,v
 1.1 2003/01/07 14:10:03 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:10:03 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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 [EMAIL PROTECTED]
   *
   * 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: InvokeTag.java,v 1.1 2003/01/07 14:10:03 dion Exp $
   */
  package org.apache.commons.jelly.tags.soap;
  
  import java.util.Collection;
  
  import javax.xml.namespace.QName;
  
  import org.apache.axis.client.Call;
  import org.apache.axis.client.Service;
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.MissingAttributeException;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /**
   * Invokes a web service
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]";>James Birchfield</a>
   * @version $Revision: 1.1 $
   */
  public class InvokeTag extends TagSupport {
  
      private String var;
      private String endpoint = null;
      private String namespace = null;
      private String method = null;
      private Service service;
      private Object params;
      
      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");
          }
          
          Object[] params = getParamArray();
          if (params == null) {
              params = new Object[]{ getBodyText() };
          }
          else {
              // invoke body just in case we have nested tags
              invokeBody(output);
          }
  
          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 answer = call.invoke(params);
          
          if (var != null) {
              context.setVariable(var, answer);
          }
          else {
              // should turn the answer into XML events...
              throw new JellyException( "Not implemented yet; should stream results as 
XML events. Results: " + answer );
          }
      }
  
  
      // 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;
      }
  
      /**
       * Sets the parameters for this SOAP call. This can be an array or collection of 
       * SOAPBodyElements or types.
       */
      public void setParams(Object params) {
          this.params = params;
      }
  
      // Implementation methods
      //-------------------------------------------------------------------------
  
      /**
       * Factory method to create a new default Service instance
       */
      protected Service createService() {
          return new Service();
      }
  
      /**
       * Performs any type coercion on the given parameters to form an Object[]
       * or returns null if no parameter has been specified
       */
      protected Object[] getParamArray() {
          if (params == null) {
              return null;
          }
          if (params instanceof Object[]) {
              return (Object[]) params;
          }
          if (params instanceof Collection) {
              Collection coll = (Collection) params;
              return coll.toArray();
          }
          // lets just wrap the current object inside an array
          return new Object[] { params };
      }
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/SoapTagLibrary.java
  
  Index: SoapTagLibrary.java
  ===================================================================
  /*
   * $Header: 
/home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/soap/src/java/org/apache/commons/jelly/tags/soap/SoapTagLibrary.java,v
 1.1 2003/01/07 14:10:03 dion Exp $
   * $Revision: 1.1 $
   * $Date: 2003/01/07 14:10:03 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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 [EMAIL PROTECTED]
   *
   * 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 2003/01/07 14:10:03 dion Exp $
   */
  package org.apache.commons.jelly.tags.soap;
  
  import org.apache.commons.jelly.TagLibrary;
  
  /** Implements general utility tags.
   *
   *  @author <a href="mailto:[EMAIL PROTECTED]";>jim birchfield</a>
   *  @version $Revision: 1.1 $
   */
  public class SoapTagLibrary extends TagLibrary
  {
      public SoapTagLibrary() {
          registerTag("invoke", InvokeTag.class);
      }
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/jelly/jelly-tags/soap/src/test/org/apache/commons/jelly/tags/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:set var="x" value="${300}"/>
        
    <soap:invoke
        var="answer"
        
endpoint="http://www.xmlbus.com:9010/xmlbus/container/Converter/ConverterService/ConverterPort/";

        namespace="urn:target-converter-service"
        method="mmToInch"
        params="${x.floatValue()}"/>
        
    <log:info>Sent: ${x} mm and received: ${answer} inches of type: 
${answer.class.name}</log:info>
  </j:jelly>
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to