dims        2003/07/09 11:50:22

  Added:       java/test/wsdl/rpcParams RpcParamsBindingImpl.java
                        RpcParamsBindingStub.java
                        RpcParamsServiceTestCase.java build.xml deploy.wsdd
                        readme.txt rpcParams.wsdl
  Log:
  Test case for Bug 20930 - Input parameter resolution by QName always fails in 1.1 
final
  from [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.1                  xml-axis/java/test/wsdl/rpcParams/RpcParamsBindingImpl.java
  
  Index: RpcParamsBindingImpl.java
  ===================================================================
  /**
   * RpcParamsBindingImpl.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package test.wsdl.rpcParams;
  
  public class RpcParamsBindingImpl implements RpcParamsTest {
      /**
       * Just return a struct with the first and second fields
       * filled out with the arguments.
       */ 
      public EchoStruct echo(String first, String second) {
          final EchoStruct result = new EchoStruct();
          result.setFirst(first);
          result.setSecond(second);
          return result;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/wsdl/rpcParams/RpcParamsBindingStub.java
  
  Index: RpcParamsBindingStub.java
  ===================================================================
  /**
   * RpcParamsBindingStub.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package test.wsdl.rpcParams;
  
  import java.util.Enumeration;
  import java.util.Vector;
  import java.util.List;
  import java.util.ArrayList;
  import java.rmi.RemoteException;
  import javax.xml.namespace.QName;
  
  import org.apache.axis.description.OperationDesc;
  import org.apache.axis.description.ParameterDesc;
  import org.apache.axis.client.Stub;
  
  public class RpcParamsBindingStub extends Stub implements RpcParamsTest {
      private Vector cachedSerClasses = new Vector();
      private Vector cachedSerQNames = new Vector();
      private Vector cachedSerFactories = new Vector();
      private Vector cachedDeserFactories = new Vector();
  
      public RpcParamsBindingStub() throws org.apache.axis.AxisFault {
           this(null);
      }
  
      public RpcParamsBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service 
service) throws org.apache.axis.AxisFault {
           this(service);
           super.cachedEndpoint = endpointURL;
      }
  
      public RpcParamsBindingStub(javax.xml.rpc.Service service) throws 
org.apache.axis.AxisFault {
          if (service == null) {
              super.service = new org.apache.axis.client.Service();
          } else {
              super.service = service;
          }
              Class cls;
              QName qName;
              Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class;
              Class beandf = 
org.apache.axis.encoding.ser.BeanDeserializerFactory.class;
              qName = new QName("urn:rpcParams.wsdl.test", "EchoStruct");
              cachedSerQNames.add(qName);
              cls = EchoStruct.class;
              cachedSerClasses.add(cls);
              cachedSerFactories.add(beansf);
              cachedDeserFactories.add(beandf);
  
      }
  
      private org.apache.axis.client.Call createCall() throws RemoteException {
          try {
              org.apache.axis.client.Call _call =
                      (org.apache.axis.client.Call) super.service.createCall();
              if (super.maintainSessionSet) {
                  _call.setMaintainSession(super.maintainSession);
              }
              if (super.cachedUsername != null) {
                  _call.setUsername(super.cachedUsername);
              }
              if (super.cachedPassword != null) {
                  _call.setPassword(super.cachedPassword);
              }
              if (super.cachedEndpoint != null) {
                  _call.setTargetEndpointAddress(super.cachedEndpoint);
              }
              if (super.cachedTimeout != null) {
                  _call.setTimeout(super.cachedTimeout);
              }
              if (super.cachedPortName != null) {
                  _call.setPortName(super.cachedPortName);
              }
              Enumeration keys = super.cachedProperties.keys();
              while (keys.hasMoreElements()) {
                  String key = (String) keys.nextElement();
                  _call.setProperty(key, super.cachedProperties.get(key));
              }
              // All the type mapping information is registered
              // when the first call is made.
              // The type mapping information is actually registered in
              // the TypeMappingRegistry of the service, which
              // is the reason why registration is only needed for the first call.
              synchronized (this) {
                  if (firstCall()) {
                      // must set encoding style before registering serializers
                      
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
                      _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);
                      for (int i = 0; i < cachedSerFactories.size(); ++i) {
                          Class cls = (Class) cachedSerClasses.get(i);
                          QName qName =
                                  (QName) cachedSerQNames.get(i);
                          Class sf = (Class)
                                   cachedSerFactories.get(i);
                          Class df = (Class)
                                   cachedDeserFactories.get(i);
                          _call.registerTypeMapping(cls, qName, sf, df, false);
                      }
                  }
              }
              return _call;
          }
          catch (Throwable t) {
              throw new org.apache.axis.AxisFault("Failure trying to get the Call 
object", t);
          }
      }
  
      /**
       * Send the given request to the server, ommitting any null parameters.
       */
      public EchoStruct echo(String first, String second) throws RemoteException {
          EchoStruct result;
          if (super.cachedEndpoint == null) {
              throw new org.apache.axis.NoEndPointException();
          }
  
          // create the operation... omit any null parameters
          OperationDesc operation = new OperationDesc();
          operation.setName("echo");
          if (first != null)
              operation.addParameter(new QName("", "first"), new 
QName("http://www.w3.org/2001/XMLSchema";, "string"), String.class, ParameterDesc.IN, 
false, false);
          if (second != null)
              operation.addParameter(new QName("", "second"), new 
QName("http://www.w3.org/2001/XMLSchema";, "string"), String.class, ParameterDesc.IN, 
false, false);
          operation.setReturnType(new QName("urn:rpcParams.wsdl.test", "EchoStruct"));
          operation.setReturnClass(EchoStruct.class);
          operation.setReturnQName(new QName("", "echoReturn"));
          operation.setStyle(org.apache.axis.enum.Style.RPC);
          operation.setUse(org.apache.axis.enum.Use.ENCODED);
  
          org.apache.axis.client.Call _call = createCall();
          _call.setOperation(operation);
          _call.setUseSOAPAction(true);
          _call.setSOAPActionURI("");
          _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
          _call.setOperationName(new QName("urn:rpcParams.wsdl.test", "echo"));
  
          setRequestHeaders(_call);
          setAttachments(_call);
  
          // add the params we're actually going to send, again ommitting nulls
          List params = new ArrayList(2);
          if (first != null)
              params.add(first);
          if (second != null)
              params.add(second);
  
          Object _resp = _call.invoke(params.toArray());
  
          if (_resp instanceof RemoteException) {
              throw (RemoteException)_resp;
          }
          else {
              getResponseHeaders(_call);
              extractAttachments(_call);
              try {
                  result = (EchoStruct) _resp;
              } catch (Exception _exception) {
                  result = (EchoStruct) org.apache.axis.utils.JavaUtils.convert(_resp, 
EchoStruct.class);
              }
          }
          return result;
      }
  
      /**
       * The same as echo, but reverse the order of parameters we send.
       */
      public EchoStruct echoReverse(String first, String second) throws 
RemoteException {
          EchoStruct result;
          if (super.cachedEndpoint == null) {
              throw new org.apache.axis.NoEndPointException();
          }
  
          // create the operation... omit any null parameters
          OperationDesc operation = new OperationDesc();
          operation.setName("echo");
          if (second != null)
              operation.addParameter(new QName("", "second"), new 
QName("http://www.w3.org/2001/XMLSchema";, "string"), String.class, ParameterDesc.IN, 
false, false);
          if (first != null)
              operation.addParameter(new QName("", "first"), new 
QName("http://www.w3.org/2001/XMLSchema";, "string"), String.class, ParameterDesc.IN, 
false, false);
          operation.setReturnType(new QName("urn:rpcParams.wsdl.test", "EchoStruct"));
          operation.setReturnClass(EchoStruct.class);
          operation.setReturnQName(new QName("", "echoReturn"));
          operation.setStyle(org.apache.axis.enum.Style.RPC);
          operation.setUse(org.apache.axis.enum.Use.ENCODED);
  
          org.apache.axis.client.Call _call = createCall();
          _call.setOperation(operation);
          _call.setUseSOAPAction(true);
          _call.setSOAPActionURI("");
          _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
          _call.setOperationName(new QName("urn:rpcParams.wsdl.test", "echo"));
  
          setRequestHeaders(_call);
          setAttachments(_call);
  
          // add the params we're actually going to send, again ommitting nulls
          List params = new ArrayList(2);
          if (second != null)
              params.add(second);
          if (first != null)
              params.add(first);
  
          Object _resp = _call.invoke(params.toArray());
  
          if (_resp instanceof RemoteException) {
              throw (RemoteException)_resp;
          }
          else {
              getResponseHeaders(_call);
              extractAttachments(_call);
              try {
                  result = (EchoStruct) _resp;
              } catch (Exception _exception) {
                  result = (EchoStruct) org.apache.axis.utils.JavaUtils.convert(_resp, 
EchoStruct.class);
              }
          }
          return result;
      }
  
  }
  
  
  
  1.1                  xml-axis/java/test/wsdl/rpcParams/RpcParamsServiceTestCase.java
  
  Index: RpcParamsServiceTestCase.java
  ===================================================================
  /**
   * RpcParamsServiceTestCase.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package test.wsdl.rpcParams;
  
  import javax.xml.rpc.ServiceException;
  
  import junit.framework.TestCase;
  
  public class RpcParamsServiceTestCase extends TestCase {
      public RpcParamsServiceTestCase(String name) {
          super(name);
      }
  
      /**
       * Send parameters in the order that they are specified in
       * the wsdl. Also omits null parameters.
       */
      public void testEcho() throws Exception {
          RpcParamsBindingStub binding = getBinding();
  
          EchoStruct result;
          // test sending both
          result = binding.echo("first", "second");
          assertNotNull("returned struct is null", result);
          assertEquals("first parameter marshalled wrong when both sent", "first", 
result.getFirst());
          assertEquals("second parameter marshalled wrong when both sent", "second", 
result.getSecond());
  
          // test ommitting the first, since it's null
          result = binding.echo(null, "second");
          assertNotNull("returned struct is null", result);
          assertNull("first parameter should be null", result.getFirst());
          assertEquals("second parameter marshalled wrong first is null", "second", 
result.getSecond());
  
          // test ommitting the second, since it's null
          result = binding.echo("first", null);
          assertNotNull("returned struct is null", result);
          assertEquals("first parameter marshalled wrong when second is null", 
"first", result.getFirst());
          assertNull("second parameter should be null", result.getSecond());
  
          // test ommitting both, since they're null
          result = binding.echo(null, null);
          assertNotNull("returned struct is null", result);
          assertNull("first parameter should be null", result.getFirst());
          assertNull("second parameter should be null", result.getSecond());
      }
  
      /**
       * Send parameters in the reverse order that they are specified in
       * the wsdl. Also omits null parameters.
       */
      public void testEchoReverse() throws Exception {
          RpcParamsBindingStub binding = getBinding();
  
          EchoStruct result;
          // test sending both
          result = binding.echoReverse("first", "second");
          assertNotNull("returned struct is null", result);
          assertEquals("first parameter marshalled wrong when both sent", "first", 
result.getFirst());
          assertEquals("second parameter marshalled wrong when both sent", "second", 
result.getSecond());
  
          // test ommitting the first, since it's null
          result = binding.echoReverse(null, "second");
          assertNotNull("returned struct is null", result);
          assertNull("first parameter should be null", result.getFirst());
          assertEquals("second parameter marshalled wrong first is null", "second", 
result.getSecond());
  
          // test ommitting the second, since it's null
          result = binding.echoReverse("first", null);
          assertNotNull("returned struct is null", result);
          assertEquals("first parameter marshalled wrong when second is null", 
"first", result.getFirst());
          assertNull("second parameter should be null", result.getSecond());
  
          // test ommitting both, since they're null
          result = binding.echoReverse(null, null);
          assertNotNull("returned struct is null", result);
          assertNull("first parameter should be null", result.getFirst());
          assertNull("second parameter should be null", result.getSecond());
      }
  
      private RpcParamsBindingStub getBinding() {
          RpcParamsBindingStub binding = null;
          try {
              binding = (RpcParamsBindingStub) new 
RpcParamsServiceLocator().getRpcParams();
          }
          catch (ServiceException jre) {
              if(jre.getLinkedCause()!=null)
                  jre.getLinkedCause().printStackTrace();
              fail("JAX-RPC ServiceException caught: " + jre);
          }
          assertNotNull("binding is null", binding);
  
          // Time out after a minute
          binding.setTimeout(60000);
          return binding;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/wsdl/rpcParams/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" ?>
  <!DOCTYPE project [
          <!ENTITY properties SYSTEM "file:../../../xmls/properties.xml">
          <!ENTITY paths  SYSTEM "file:../../../xmls/path_refs.xml">
          <!ENTITY taskdefs SYSTEM "file:../../../xmls/taskdefs.xml">
          <!ENTITY taskdefs_post_compile SYSTEM 
"file:../../../xmls/taskdefs_post_compile.xml">
          <!ENTITY targets SYSTEM "file:../../../xmls/targets.xml">
  ]>
  
  <!-- ===================================================================
  <description>
     Test/Sample Component file for Axis
  
  Notes:
     This is a build file for use with the Jakarta Ant build tool.
  
  Prerequisites:
  
     jakarta-ant from http://jakarta.apache.org
  
  Build Instructions:
     To compile
          ant compile
     To execute
          ant run
  
  Author:
    Matt Seibert [EMAIL PROTECTED]
  
  Copyright:
    Copyright (c) 2002-2003 Apache Software Foundation.
  </description>
  ==================================================================== -->
  
  <project default="compile">
  
      <property name="axis.home" location="../../.."/>
      <property name="componentName" value="test/wsdl/rpcParams"/>
      &properties;
      &paths;
      &taskdefs;
      &taskdefs_post_compile;
      &targets;
  
      <target name="clean">
          <echo message="Removing ${build.dir}/classes/${componentName} and 
${build.dir}/work/${componentName}"/>
          <delete dir="${build.dir}/classes/${componentName}"/>
          <delete dir="${build.dir}/work/${componentName}"/>
      </target>
  
      <target name="copy" depends="setenv"/>
  
      <target name="compile" depends="copy">
          <echo message="Compiling test.wsdl.rpcParams"/>
          <!-- This tests rpcParams.  -->
          <wsdl2java url="${axis.home}/test/wsdl/rpcParams/rpcParams.wsdl"
              output="${axis.home}/build/work"
              serverSide="yes"
              testcase="yes">
          </wsdl2java>
  
          <copy todir="${build.dir}/work/test/wsdl/rpcParams" overwrite="yes">
              <fileset dir="${axis.home}/test/wsdl/rpcParams">
                  <include name="*TestCase.java"/>
                  <include name="*Impl.java"/>
                  <include name="*Stub.java"/>
                  <include name="*.wsdd"/>
              </fileset>
          </copy>
  
          <javac srcdir="${build.dir}/work" destdir="${build.dest}" 
fork="${javac.fork}"
              debug="${debug}">
              <classpath refid="classpath"/>
              <include name="test/wsdl/rpcParams/*.java"/>
          </javac>
  
      </target>
  
      <target name="run">
          <antcall target="execute-Component"/>
      </target>
  
  </project>
  
  
  
  1.1                  xml-axis/java/test/wsdl/rpcParams/deploy.wsdd
  
  Index: deploy.wsdd
  ===================================================================
  <!-- Use this file to deploy some handlers/chains and services      -->
  <!-- Two ways to do this:                                           -->
  <!--   java org.apache.axis.client.AdminClient deploy.wsdd          -->
  <!--      after the axis server is running                          -->
  <!-- or                                                             -->
  <!--   java org.apache.axis.utils.Admin client|server deploy.wsdd   -->
  <!--      from the same directory that the Axis engine runs         -->
  
  <deployment
      xmlns="http://xml.apache.org/axis/wsdd/";
      xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
  
    <!-- Services from rpcParamsService WSDL service -->
  
    <service name="RpcParams" provider="java:RPC" style="rpc" use="encoded">
        <parameter name="wsdlTargetNamespace" value="urn:rpcParams.wsdl.test"/>
        <parameter name="wsdlServiceElement" value="rpcParamsService"/>
        <parameter name="wsdlServicePort" value="RpcParams"/>
        <parameter name="className" value="test.wsdl.rpcParams.RpcParamsBindingImpl"/>
        <parameter name="allowedMethods" value="echo"/>
  
        <!--
          NOTE: it is important to *not* include metadata about the service's operation
          here in order to reproduce bug the bug in ServiceDesc mentioned in
          http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20930.
        -->
  
        <typeMapping
          xmlns:ns="urn:rpcParams.wsdl.test"
          qname="ns:EchoStruct"
          type="java:test.wsdl.rpcParams.EchoStruct"
          serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
          deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
          encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
        />
    </service>
  </deployment>
  
  
  
  1.1                  xml-axis/java/test/wsdl/rpcParams/readme.txt
  
  Index: readme.txt
  ===================================================================
  This is a simple test case to test parameter handling in an RPC/Encoded
  web service. It tests two scenarios:
    1) Null parameters to an operation may be ommitted.
    2) Parameters to an operation may be sent in any order.
  
  To accomplish this, a custom binding stub implementation is provided, since
  the default wsdl2Java versions at the time of writing never reorder or omit
  null parameters.
  
  The test case was originally created to validate bug
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20930.
  
   - [EMAIL PROTECTED]
  
  
  1.1                  xml-axis/java/test/wsdl/rpcParams/rpcParams.wsdl
  
  Index: rpcParams.wsdl
  ===================================================================
  <?xml version="1.0" ?>
  
  <definitions
      name="rpcParams test"
      targetNamespace="urn:rpcParams.wsdl.test"
      xmlns:tns="urn:rpcParams.wsdl.test"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema";
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
      xmlns="http://schemas.xmlsoap.org/wsdl/";>
  
      <types>
          <schema xmlns="http://www.w3.org/2001/XMLSchema";>
              <import namespace="http://schemas.xmlsoap.org/soap/encoding/"; />
              <complexType name="EchoStruct">
                  <sequence>
                      <element name="first" nillable="true" type="xsd:string" />
                      <element name="second" nillable="true" type="xsd:string" />
                  </sequence>
              </complexType>
          </schema>
      </types>
  
    <!-- message declns -->
    <message name="echoRequest">
        <part name="first" type="xsd:string"/>
        <part name="second" type="xsd:string"/>
    </message>
  
    <message name="echoResponse">
        <part name="echoReturn" type="tns:EchoStruct"/>
    </message>
  
    <!-- port type declns -->
    <portType name="rpcParamsTest">
      <operation name="echo" parameterOrder="first second">
        <input message="tns:echoRequest" name="echoRequest"/>
        <output message="tns:echoResponse" name="echoResponse"/>
      </operation>
    </portType>
  
    <!-- binding declns -->
    <binding name="rpcParamsBinding" type="tns:rpcParamsTest">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="echo">
        <soap:operation soapAction=""/>
        <input name="echoRequest">
          <soap:body
              use="encoded"
              namespace="urn:rpcParams.wsdl.test"
              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <soap:body name="echoResponse"
              use="encoded"
              namespace="urn:rpcParams.wsdl.test"
              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
    </binding>
  
    <!-- service decln -->
    <service name="rpcParamsService">
      <port name="RpcParams" binding="tns:rpcParamsBinding">
        <soap:address location="http://localhost:8080/axis/services/RpcParams"/>
      </port>
    </service>
  
  </definitions>
  
  
  
  

Reply via email to