You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2003/12/09 19:42:21 UTC

cvs commit: ws-axis/java/src/org/apache/axis Message.java

dims        2003/12/09 10:42:21

  Modified:    java/src/org/apache/axis Message.java
  Added:       java/test/wsdl/jaxrpchandler2 build.xml deploy.wsdd
                        EchoServiceImpl.java EchoServiceServerHandler.java
                        JAXRPCHandler2TestCase.java undeploy.wsdd
  Log:
  Fix and test case for Bug 16418 - No deserialization context after changing SOAPBody in handler
  
  Revision  Changes    Path
  1.1                  ws-axis/java/test/wsdl/jaxrpchandler2/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 mseibert@us.ibm.com
  
  Copyright:
    Copyright (c) 2002-2003 Apache Software Foundation.
  </description>
  ==================================================================== -->
  
  <project default="compile">
  
          <property name="axis.home" location="../../../" />
  	<property name="componentName" value="test/wsdl/jaxrpchandler2"/>
  
          &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.${componentName}"/>
      <!-- This is (OK, "will be") a comprehensive test of XML schema types -->
      <copy todir="${build.dir}/work/test/wsdl/jaxrpchandler2" overwrite="yes">
        <fileset dir="${axis.home}/test/wsdl/jaxrpchandler2">
          <include name="*TestCase.java"/>
          <include name="*Impl.java"/>
  	<include name="*Handler.java"/>
        </fileset>
      </copy>
  
   <copy todir="${build.dir}/work/test/wsdl/jaxrpchandler2" overwrite="yes">
      <fileset dir="${axis.home}/test/wsdl/jaxrpchandler2">
        <include name="*.wsdd"/>
      </fileset>
    </copy>
  
    <javac srcdir="${build.dir}/work/test/wsdl/jaxrpchandler2" destdir="${build.dest}" debug="${debug}" fork="${javac.fork}">
      <classpath>
          <path refid="classpath"/>
      </classpath>
      <include name="*.java"/>
    </javac>
  </target>
  
  <target name="run">
  	<antcall target="execute-Component" />
  </target>
  
  </project>
  
  
  
  1.1                  ws-axis/java/test/wsdl/jaxrpchandler2/deploy.wsdd
  
  Index: deploy.wsdd
  ===================================================================
  <deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
      xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
    <service name="EchoService" provider="java:RPC">
      <parameter name="className" value="test.wsdl.jaxrpchandler2.EchoServiceImpl" />
      <parameter name="allowedMethods" value="echo" />
      <requestFlow>
        <handler type="java:org.apache.axis.handlers.JAXRPCHandler">
          <parameter name="className" value="test.wsdl.jaxrpchandler2.EchoServiceServerHandler" />
        </handler>
      </requestFlow>
    </service>
  </deployment>
  
  
  
  1.1                  ws-axis/java/test/wsdl/jaxrpchandler2/EchoServiceImpl.java
  
  Index: EchoServiceImpl.java
  ===================================================================
  package test.wsdl.jaxrpchandler2;
  
  public class EchoServiceImpl {
  
      public String echo(String echoString) {
  	return echoString;
      }
      
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/jaxrpchandler2/EchoServiceServerHandler.java
  
  Index: EchoServiceServerHandler.java
  ===================================================================
  package test.wsdl.jaxrpchandler2;
  
  import java.io.*;
  import java.io.InputStream;
  import java.util.*;
  import java.util.Iterator;
  
  import javax.xml.namespace.QName;
  import javax.xml.rpc.handler.*;
  import javax.xml.rpc.handler.soap.SOAPMessageContext;
  import javax.xml.soap.*;
  import javax.xml.soap.SOAPMessage;
  import javax.xml.transform.stream.*;
  
  public class EchoServiceServerHandler implements Handler {
  
      public boolean handleRequest(MessageContext messageContext) {
  
  	try {
  	    SOAPMessageContext soapMsgCtx = (SOAPMessageContext) messageContext;
  	    
  	    SOAPMessage soapMsg = soapMsgCtx.getMessage();
  	    SOAPPart soapPart = soapMsg.getSOAPPart();
  	    SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
  	    soapEnvelope.getBody().detachNode();
  	    SOAPBody soapBody = soapEnvelope.addBody();
  	    SOAPBodyElement echoElement = soapBody.addBodyElement(soapEnvelope.createName("echo", "ns1", "http://soapinterop.org/"));
  	    SOAPElement argElement = echoElement.addChildElement("arg0");
  	    argElement = argElement.addAttribute(soapEnvelope.createName("type", "xsi", "http://www.w3.org/2001/XMLSchema-instance"), "xsd:string");
  	    argElement.addTextNode("my echo string");
  	    soapMsg.saveChanges();
  	    
  	} catch (Exception e) {
  	    e.printStackTrace();
  	}
  	
  	return true;
      }
      
      public boolean handleResponse(MessageContext messageContext) {
  	return true;
      }
  
      
      public boolean handleFault(MessageContext messageContext) {
  	return true;
      }
  
      public void init(HandlerInfo arg0) {
      }
  
      public void destroy() {
      }
  
      public QName[] getHeaders() {
  	return null;
      }
      
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/jaxrpchandler2/JAXRPCHandler2TestCase.java
  
  Index: JAXRPCHandler2TestCase.java
  ===================================================================
  package test.wsdl.jaxrpchandler2;
  
  import java.rmi.RemoteException;
  
  import javax.xml.namespace.QName;
  import javax.xml.rpc.*;
  
  import junit.framework.TestCase;
  
  public class JAXRPCHandler2TestCase extends TestCase {
  
      protected String serviceEndpointUrl =
  	"http://localhost:8080/axis/services/EchoService";
      protected String qnameService = "EchoService";
      protected String qnamePort = "EchoServicePort";
      
      protected Call call;
      
      protected String echoString = "my echo string";
      
      public JAXRPCHandler2TestCase(String arg0) {
  	super(arg0);
      }
  
      public void testJAXRPCHandler2() {
  	call.setOperationName(new QName("http://soapinterop.org/", "echo"));
  	String returnString = null;
  	try {
  	    returnString = (String) call.invoke(new Object[] { echoString });
  	} catch (RemoteException e) {
  	    e.printStackTrace();
  	    fail("Remote exception while calling invoke");
  	}
  	
  	assertEquals(
  		     "returnString does not match echoString",
  		     echoString,
  		     returnString);
      }
      
      protected void setUp() throws Exception {
  	super.setUp();
  
  	ServiceFactory serviceFactory = ServiceFactory.newInstance();
  	Service service = serviceFactory.createService(new QName(qnameService));
  	call = service.createCall(new QName(qnamePort));
  	call.setTargetEndpointAddress(serviceEndpointUrl);
      }
  
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/jaxrpchandler2/undeploy.wsdd
  
  Index: undeploy.wsdd
  ===================================================================
  <undeployment name="test" xmlns="http://xml.apache.org/axis/wsdd/">
    <service name="EchoService"/>
  </undeployment>
  
  
  
  1.104     +6 -0      ws-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- Message.java	1 Dec 2003 17:57:31 -0000	1.103
  +++ Message.java	9 Dec 2003 18:42:21 -0000	1.104
  @@ -616,6 +616,12 @@
               }
           }
           saveRequired = false;
  +        try {
  +            /* Fix for Bug 16418 - Start from scratch */ 
  +            getSOAPPartAsString();
  +        } catch (AxisFault axisFault) {
  +            log.error(Messages.getMessage("exception00"), axisFault);
  +        }
       }
   
       /**