dims, sorry I didn't get back to you on this one sooner, but it slipped under my radar screen and I just found myself browsing through the Service class and the Call object issue struck me again. I hadn't realized you were going to put this into the CVS. When we were chatting about it I thought it was just a hack that you were going to apply to your own codebase. I really don't like this solution for 'caching' the last Call object. I had 2 issues: 1. multithreading issues 2. multiple ports on a service issues
You've covered my #1 concerns by using ThreadLocal storage. But #2 is still a problem. Given the following WSDL: <service name="service"> <port name="p1" binding="b1" .../> <port name="p2" binding="b2" .../> </service> A client could call stubs for both p1 and p2 in the same thread. The Call objects the stubs would be using would get mixed up since they both go through the Service to get the Call objects. What was the reason for putting the createCall/getCall methods on the service? I believe putting createCall/getCall on the Stub would fix my issue, but I seem to remember that you had a good reason for putting them on the Service class. Russell Butek [EMAIL PROTECTED] [EMAIL PROTECTED] on 03/20/2002 03:52:23 PM Please respond to [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: Subject: cvs commit: xml-axis/java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java dims 02/03/20 13:52:23 Modified: java/src/org/apache/axis/client Service.java java/src/org/apache/axis/wsdl/toJava JavaStubWriter.java Log: - Adding support in Stub to keep track of the last "call". - Using TLS to avoid threading problems. - Stub's getCall() can be used to get the last "call" - Renaming getCall() in generated code to createCall() as a new call is created everytime. Revision Changes Path 1.44 +19 -8 xml-axis/java/src/org/apache/axis/client/Service.java Index: Service.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Service.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- Service.java 20 Feb 2002 14:11:17 -0000 1.43 +++ Service.java 20 Mar 2002 21:52:23 -0000 1.44 @@ -55,7 +55,6 @@ package org.apache.axis.client ; -import javax.wsdl.extensions.soap.SOAPAddress; import org.apache.axis.AxisEngine; import org.apache.axis.EngineConfiguration; import org.apache.axis.configuration.DefaultEngineConfigurationFactory; @@ -66,11 +65,11 @@ import javax.naming.Reference; import javax.naming.Referenceable; import javax.naming.StringRefAddr; - import javax.wsdl.Binding; import javax.wsdl.Definition; import javax.wsdl.Port; import javax.wsdl.PortType; +import javax.wsdl.extensions.soap.SOAPAddress; import javax.wsdl.factory.WSDLFactory; import javax.wsdl.xml.WSDLReader; import javax.xml.rpc.ServiceException; @@ -80,6 +79,7 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.io.Serializable; +import java.lang.reflect.Proxy; import java.net.MalformedURLException; import java.net.URL; import java.util.HashSet; @@ -87,7 +87,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import java.lang.reflect.Proxy; /** * Axis' JAXRPC Dynamic Invoation Interface implementation of the Service @@ -111,6 +110,10 @@ private javax.wsdl.Service wsdlService = null ; private boolean maintainSession = false ; + /** + * Thread local storage used for storing the last call object + */ + private static ThreadLocal previousCall = new ThreadLocal(); Definition getWSDLDefinition() { return( wsdlDefinition ); @@ -291,7 +294,8 @@ } try { - Call call = new Call(endpoint); + Call call = (org.apache.axis.client.Call)createCall(); + call.setTargetEndpointAddress(new URL(endpoint)); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); return (java.rmi.Remote)Proxy.newProxyInstance(classLoader, @@ -326,7 +330,7 @@ if ( portType == null ) throw new ServiceException( JavaUtils.getMessage ("noPortType00", "" + portName) ); - org.apache.axis.client.Call call = new org.apache.axis.client.Call(this); + Call call = (org.apache.axis.client.Call)createCall(); call.setPortTypeName( portName ); // Get the URL @@ -364,7 +368,7 @@ String operationName) throws ServiceException { - org.apache.axis.client.Call call=new org.apache.axis.client.Call(this); + Call call = (org.apache.axis.client.Call)createCall(); call.setOperation( portName, operationName ); return( call ); } @@ -383,7 +387,7 @@ QName operationName) throws ServiceException { - org.apache.axis.client.Call call=new org.apache.axis.client.Call(this); + Call call = (org.apache.axis.client.Call)createCall(); call.setOperation( portName, operationName.getLocalPart() ); return( call ); } @@ -397,7 +401,9 @@ * @throws ServiceException If there's an error */ public javax.xml.rpc.Call createCall() throws ServiceException { - return( new org.apache.axis.client.Call(this) ); + Call call = new org.apache.axis.client.Call(this); + previousCall.set(call); + return call; } /** @@ -565,5 +571,10 @@ */ public boolean getMaintainSession() { return maintainSession; + } + + public Call getCall() throws ServiceException { + Call call = (Call) previousCall.get(); + return call; } } 1.49 +2 -2 xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java Index: JavaStubWriter.java =================================================================== RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- JavaStubWriter.java 20 Mar 2002 20:53:56 -0000 1.48 +++ JavaStubWriter.java 20 Mar 2002 21:52:23 -0000 1.49 @@ -167,7 +167,7 @@ pw.println(" }"); pw.println(); - pw.println(" private org.apache.axis.client.Call getCall() throws java.rmi.RemoteException {"); + pw.println(" private org.apache.axis.client.Call createCall() throws java.rmi.RemoteException {"); pw.println(" try {"); pw.println(" org.apache.axis.client.Call call ="); pw.println(" (org.apache.axis.client.Call) super.service.createCall();"); @@ -493,7 +493,7 @@ pw.println(" if (super.cachedEndpoint == null) {"); pw.println(" throw new org.apache.axis.NoEndPointException();"); pw.println(" }"); - pw.println(" org.apache.axis.client.Call call = getCall ();"); + pw.println(" org.apache.axis.client.Call call = createCall();"); // loop over paramters and set up in/out params for (int i = 0; i < parms.list.size(); ++i) {