You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by de...@apache.org on 2006/07/21 11:25:36 UTC

svn commit: r424242 - in /webservices/axis2/trunk/java/modules: core/src/org/apache/axis2/context/ServiceContext.java core/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java integration/test/org/apache/axis2/spring/SpringServiceTest.java

Author: deepal
Date: Fri Jul 21 02:25:36 2006
New Revision: 424242

URL: http://svn.apache.org/viewvc?rev=424242&view=rev
Log:
- fixing AXIS2-911 and 794
          

Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/spring/SpringServiceTest.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java?rev=424242&r1=424241&r2=424242&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java Fri Jul 21 02:25:36 2006
@@ -45,7 +45,7 @@
         super(serviceGroupContext);
         this.serviceGroupContext = serviceGroupContext;
         this.axisService = serviceConfig;
-        this.configContext =(ConfigurationContext) parent.getParent();
+        this.configContext = (ConfigurationContext) parent.getParent();
     }
 
     public OperationContext createOperationContext(QName name) {
@@ -67,10 +67,11 @@
     }
 
     /**
-     *  To get the ERP for a given service , if the transport is present and not
+     * To get the ERP for a given service , if the transport is present and not
      * running then it will add as a listener to ListenerManager , there it will
      * init that and start the listener , and finally ask the EPR from tarnsport
      * for a given service
+     *
      * @param transport : Name of the transport
      * @return
      * @throws AxisFault
@@ -106,6 +107,18 @@
     }
 
     public EndpointReference getMyEPR() {
+        if (myEPR == null) {
+            try {
+                if (ListenerManager.defaultConfigurationContext != null) {
+                    ListenerManager listenerManager =
+                            ListenerManager.defaultConfigurationContext.getListenerManager();
+                    myEPR = listenerManager.getEPRforService(axisService.getName(), null, null);
+                }
+            } catch (AxisFault axisFault) {
+                // what else I can do 
+                myEPR = null;
+            }
+        }
         return myEPR;
     }
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=424242&r1=424241&r2=424242&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Fri Jul 21 02:25:36 2006
@@ -1,6 +1,7 @@
 package org.apache.axis2.description;
 
 import com.ibm.wsdl.extensions.soap.SOAPConstants;
+import com.ibm.wsdl.util.xml.DOM2Writer;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.wsdl.WSDL11ActionHelper;
@@ -17,17 +18,14 @@
 import org.apache.ws.policy.util.PolicyFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
 
 import javax.wsdl.*;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.UnknownExtensibilityElement;
 import javax.wsdl.extensions.schema.Schema;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.extensions.soap.SOAPBinding;
-import javax.wsdl.extensions.soap.SOAPHeader;
-import javax.wsdl.extensions.soap.SOAPOperation;
-import javax.wsdl.extensions.soap.SOAPBody;
+import javax.wsdl.extensions.soap.*;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLLocator;
 import javax.wsdl.xml.WSDLReader;
@@ -179,7 +177,6 @@
             axisService.setTargetNamespace(wsdl4jDefinition
                     .getTargetNamespace());
 
-
             //adding ns in the original WSDL
             processPoliciesInDefintion(wsdl4jDefinition);
 
@@ -194,7 +191,7 @@
 
             // create new Schema extensions element for wrapping
             //(if its present)
-            Element[] schemaElements = generateWrapperSchema(schemaMap,binding);
+            Element[] schemaElements = generateWrapperSchema(schemaMap, binding);
 
             //we might have modified the schemas by now so the addition should
             //happen here
@@ -219,7 +216,13 @@
             // copy the documentation element contentto the description
             Element documentationElement = wsdl4jDefinition.getDocumentationElement();
             if (documentationElement != null) {
-                String serviceDes = documentationElement.getFirstChild().toString();
+                Node firstChild = documentationElement.getFirstChild();
+                String serviceDes;
+                if (firstChild.getNodeType() == Node.TEXT_NODE) {
+                    serviceDes = firstChild.getNodeValue();
+                } else {
+                    serviceDes = DOM2Writer.nodeToString(firstChild);
+                }
                 axisService.setServiceDescription(serviceDes);
             }
             processBinding(binding, wsdl4jDefinition);
@@ -236,6 +239,7 @@
      * Populate a map of targetNamespace vs DOM schema element
      * This is used to grab the correct schema element when adding
      * a new element
+     *
      * @param wsdl4jTypes
      * @return
      */
@@ -244,11 +248,11 @@
         List typesExtensibilityElements = wsdl4jTypes.getExtensibilityElements();
         Map schemaMap = new HashMap();
         for (int i = 0; i < typesExtensibilityElements.size(); i++) {
-            Object o =  typesExtensibilityElements.get(i);
-            if (o instanceof Schema){
-                Schema s = (Schema)o;
+            Object o = typesExtensibilityElements.get(i);
+            if (o instanceof Schema) {
+                Schema s = (Schema) o;
                 String targetNamespace = s.getElement().getAttribute(TRAGET_NAMESPACE);
-                schemaMap.put(targetNamespace,s.getElement());
+                schemaMap.put(targetNamespace, s.getElement());
             }
         }
         return schemaMap;
@@ -351,7 +355,7 @@
      * @throws Exception
      */
     private void processBinding(
-            Binding binding, Definition dif)  throws Exception {
+            Binding binding, Definition dif) throws Exception {
         if (binding != null) {
             copyExtensibleElements(binding.getExtensibilityElements(), dif,
                     axisService, BINDING);
@@ -446,7 +450,7 @@
                     Fault wsdl4jFault = wsdl4jOperation.getFault(bindingFault.getName());
                     AxisMessage faultMessage = findFaultMessage(wsdl4jFault.getMessage().getQName().getLocalPart(), operation.getFaultMessages());
 
-                    AddQNameReference(faultMessage,wsdl4jFault.getMessage());
+                    AddQNameReference(faultMessage, wsdl4jFault.getMessage());
 
 
                 }
@@ -458,6 +462,7 @@
     /**
      * Find the fault message relevant to a given name
      * from the fault message list
+     *
      * @param name
      * @param faultMessages
      * @return
@@ -497,7 +502,7 @@
             if (extElement instanceof SOAPBody) {
                 SOAPBody soapBody = (SOAPBody) extElement;
                 List bindingPartsList = soapBody.getParts();
-                if (bindingPartsList!=null && !bindingPartsList.isEmpty()) {
+                if (bindingPartsList != null && !bindingPartsList.isEmpty()) {
                     //we can process a single part only
                     processPartsList(bindingPartsList, wsdl4jMessage, inMessage);
                     // there are no parts named in the binding - process the items normally
@@ -540,6 +545,7 @@
 
     /**
      * A reusable method to both the input and output QName populators
+     *
      * @param bindingPartsList
      * @param wsdl4jMessage
      * @param inMessage
@@ -587,7 +593,7 @@
             if (extElement instanceof SOAPBody) {
                 SOAPBody soapBody = (SOAPBody) extElement;
                 List bindingPartsList = soapBody.getParts();
-                if (bindingPartsList!=null && !bindingPartsList.isEmpty()) {
+                if (bindingPartsList != null && !bindingPartsList.isEmpty()) {
                     //we can process a single part only so delegate the task
                     //of processing
                     processPartsList(bindingPartsList, wsdl4jMessage, outMessage);
@@ -640,25 +646,22 @@
      * @param isWrapped
      */
     private void AddQNameReference(AxisMessage faultMessage,
-                                   Message wsdl4jMessage){
-
+                                   Message wsdl4jMessage) {
 
         // for a fault this is trivial - All faults are related directly to a
         // message by the name and are supposed to have a single part. So it is
         // a matter of copying the right QName from the message part
 
         //get the part
-        Part wsdl4jMessagePart = (Part)wsdl4jMessage.getParts().values().toArray()[0];
-        if (wsdl4jMessagePart==null){
+        Part wsdl4jMessagePart = (Part) wsdl4jMessage.getParts().values().toArray()[0];
+        if (wsdl4jMessagePart == null) {
             throw new WSDLProcessingException();
         }
         faultMessage.setElementQName(wsdl4jMessagePart.getElementName());
 
 
-
-
-
     }
+
     /**
      * A util method that returns the SOAP style
      * included in the binding operation
@@ -715,7 +718,7 @@
      * @throws Exception
      */
     private AxisOperation populateOperations(Operation wsdl4jOperation, PortType wsdl4jPortType,
-                                             Definition dif ) throws Exception {
+                                             Definition dif) throws Exception {
         QName opName = new QName(wsdl4jOperation.getName());
         //Copy Name Attribute
         AxisOperation axisOperation = axisService.getOperation(opName);
@@ -890,7 +893,7 @@
         List schemaElementList = new ArrayList();
         //target namespace for this should be the namespace URI for
         //the porttype
-        String porttypeNamespaceURI =wsdl4jBinding.getPortType().
+        String porttypeNamespaceURI = wsdl4jBinding.getPortType().
                 getQName().getNamespaceURI();
 
         ////////////////////////////////////////////////////////////////////////
@@ -914,6 +917,7 @@
 
     /**
      * Create a schema by looking at the port type
+     *
      * @param namespaceURI
      * @return null if there is no element
      */
@@ -1178,9 +1182,9 @@
         // insert the elements there rather than creating a new Schema element
         ////////////////////////////////////////////////////////////////////////
         //
-        if (existingSchemaMap.containsKey(namespaceURI)){
+        if (existingSchemaMap.containsKey(namespaceURI)) {
             //get the relevant schema element
-            Element schemaElement = (Element)existingSchemaMap.get(namespaceURI);
+            Element schemaElement = (Element) existingSchemaMap.get(namespaceURI);
             Document ownerDocument = schemaElement.getOwnerDocument();
 
             //loop through the namespace declarations first and add them
@@ -1188,15 +1192,15 @@
                     .keySet().toArray(new String[namespacePrefixMap.size()]);
             for (int i = 0; i < nameSpaceDeclarationArray.length; i++) {
                 String s = nameSpaceDeclarationArray[i];
-                checkAndAddNamespaceDeclarations(s,namespacePrefixMap,schemaElement);
+                checkAndAddNamespaceDeclarations(s, namespacePrefixMap, schemaElement);
             }
 
-             //add imports  - check whether it is the targetnamespace before
+            //add imports  - check whether it is the targetnamespace before
             // adding
             Element[] namespaceImports = (Element[]) namespaceImportsMap.values()
                     .toArray(new Element[namespaceImportsMap.size()]);
             for (int i = 0; i < namespaceImports.length; i++) {
-                if (!namespaceURI.equals(namespaceImports[i].getAttribute(NAMESPACE_URI))){
+                if (!namespaceURI.equals(namespaceImports[i].getAttribute(NAMESPACE_URI))) {
                     schemaElement.appendChild(namespaceImports[i]);
                 }
             }
@@ -1205,7 +1209,7 @@
                     .toArray(new Element[elementElementsList.size()]);
             for (int i = 0; i < elementDeclarations.length; i++) {
                 schemaElement.appendChild(ownerDocument.
-                        importNode(elementDeclarations[i],true));
+                        importNode(elementDeclarations[i], true));
             }
 
             //don't return anything!!
@@ -1255,7 +1259,6 @@
     }
 
     /**
-     *
      * @param namespaceDeclaration
      * @param prefixMap
      */
@@ -1263,33 +1266,33 @@
                                                   Map prefixMap,
                                                   Element schemaElement) {
         //get the attribute for the current namespace
-        String prefix = (String)prefixMap.get(namespace);
+        String prefix = (String) prefixMap.get(namespace);
         //A prefix must be found at this point!
         String existingURL = schemaElement.getAttributeNS(
                 XML_NAMESPACE_URI,
                 NAMESPACE_DECLARATION_PREFIX + prefix);
-        if (existingURL==null){
+        if (existingURL == null) {
             //there is no existing URL by that prefix - declare a new namespace
             schemaElement.setAttributeNS(XML_NAMESPACE_URI,
                     NAMESPACE_DECLARATION_PREFIX + prefix,
                     namespace);
-        }else if (existingURL.equals(namespace)){
+        } else if (existingURL.equals(namespace)) {
             //this namespace declaration is already there with the same prefix
             //ignore it
-        }else{
+        } else {
             //there is a different namespace declared in the given prefix
             //change the prefix in the prefix map to a new one and declare it
 
             //create a prefix
-            String generatedPrefix = "ns" +prefixCounter++;
-            while(prefixMap.containsKey(generatedPrefix)){
-                generatedPrefix = "ns" +prefixCounter++;
+            String generatedPrefix = "ns" + prefixCounter++;
+            while (prefixMap.containsKey(generatedPrefix)) {
+                generatedPrefix = "ns" + prefixCounter++;
             }
             schemaElement.setAttributeNS(XML_NAMESPACE_URI,
                     NAMESPACE_DECLARATION_PREFIX + generatedPrefix,
                     namespace);
             //add to the map
-            prefixMap.put(generatedPrefix,namespace);
+            prefixMap.put(generatedPrefix, namespace);
         }
 
     }
@@ -1379,7 +1382,7 @@
     private Definition readInTheWSDLFile(InputStream in) throws WSDLException {
 
         WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
-        
+
         //switch off the verbose mode for all usecases
         reader.setFeature("javax.wsdl.verbose", false);
 
@@ -1899,7 +1902,7 @@
     /**
      * Inner class declaration for the processing exceptions
      */
-    public static class WSDLProcessingException extends RuntimeException{
+    public static class WSDLProcessingException extends RuntimeException {
         public WSDLProcessingException() {
         }
 

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/spring/SpringServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/spring/SpringServiceTest.java?rev=424242&r1=424241&r2=424242&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/spring/SpringServiceTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/spring/SpringServiceTest.java Fri Jul 21 02:25:36 2006
@@ -18,48 +18,33 @@
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
-import junit.framework.TestCase;
-import junit.framework.Assert;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.databinding.utils.BeanUtil;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.InOutAxisOperation;
-import org.apache.axis2.description.OutInAxisOperation;
-import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.util.TestConstants;
 import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier;
 import org.apache.axis2.integration.UtilServer;
 import org.apache.axis2.integration.UtilServerBasedTestCase;
-import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
+import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
 import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 import javax.xml.namespace.QName;
-import javax.xml.stream.FactoryConfigurationError;
 import javax.xml.stream.XMLOutputFactory;
 import java.io.StringWriter;
 
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
 public class SpringServiceTest extends UtilServerBasedTestCase {
 
     protected QName transportName = new QName("http://springExample.org/example1",
@@ -67,7 +52,7 @@
     EndpointReference targetEPR = new EndpointReference(
             "http://127.0.0.1:" + (UtilServer.TESTING_PORT)
 //            "http://127.0.0.1:" + 5556
-                  //  + "/axis2/services/EchoXMLService/echoOMElement");
+                    //  + "/axis2/services/EchoXMLService/echoOMElement");
                     + "/axis2/services/SpringExample/getValue");
 
     protected AxisConfiguration engineRegistry;
@@ -84,7 +69,7 @@
 
     protected void setUp() throws Exception {
 
-        AxisService service = 
+        AxisService service =
                 createSpringService(springServiceName, new RawXMLINOutMessageReceiver(),
                         "org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier",
                         "springAwareService",
@@ -114,21 +99,21 @@
 
         OMFactory factory = OMAbstractFactory.getOMFactory();
         OMNamespace omNs = factory.createOMNamespace(
-        		"http://springExample.org/example1", "example1");
-        
+                "http://springExample.org/example1", "example1");
+
         OMElement method = factory.createOMElement("getValue", omNs);
         OMElement value = factory.createOMElement("Text", omNs);
         value.addChild(factory.createOMText(value, "Test String "));
         method.addChild(value);
-              
+
         Options options = new Options();
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
         options.setTo(targetEPR);
         options.setAction(springOperationName.getLocalPart());
         sender.setOptions(options);
-       
+
         OMElement result = sender.sendReceive(springOperationName, method);
-  
+
         StringWriter writer = new StringWriter();
         result.serialize(XMLOutputFactory.newInstance()
                 .createXMLStreamWriter(writer));
@@ -136,11 +121,11 @@
         String testStr = writer.toString();
         // write to report
         System.out.println("\ntestSpringAppContextAwareObjectSupplier result: " + testStr);
-        assertNotSame(new Integer(testStr.indexOf("emerge thyself")), new Integer(-1));       
+        assertNotSame(new Integer(testStr.indexOf("emerge thyself")), new Integer(-1));
     }
 
     private AxisService createSpringService(QName springServiceName,
-        MessageReceiver messageReceiver, String supplierName, String beanName, QName opName) throws AxisFault {
+                                            MessageReceiver messageReceiver, String supplierName, String beanName, QName opName) throws AxisFault {
 
         AxisService service = new AxisService(springServiceName.getLocalPart());
 
@@ -159,10 +144,10 @@
     }
 
     public AxisService createSpringServiceforClient(QName springServiceName,
-                                                           MessageReceiver messageReceiver,
-                                                           String supplierName,
-                                                           String beanName,
-                                                           QName opName)
+                                                    MessageReceiver messageReceiver,
+                                                    String supplierName,
+                                                    String beanName,
+                                                    QName opName)
             throws AxisFault {
         AxisService service = new AxisService(springServiceName.getLocalPart());
 
@@ -182,7 +167,7 @@
     public void createSpringAppCtx(ClassLoader cl)
             throws Exception {
 
-        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {"/spring/applicationContext.xml"}, false);
+        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"/spring/applicationContext.xml"}, false);
         ctx.setClassLoader(cl);
         ctx.refresh();
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org