You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2007/11/07 22:04:35 UTC

svn commit: r592898 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/model/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/databinding/aegis/src/...

Author: bimargulies
Date: Wed Nov  7 13:04:34 2007
New Revision: 592898

URL: http://svn.apache.org/viewvc?rev=592898&view=rev
Log:
Rename SoapConstants to SoapBindingConstants so that we no longer have SOAPConstants and SoapConstants in two different packages. Add constants for the two binding ids. continue eaking along toward javascript function generation.

Added:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConstants.java
      - copied, changed from r592846, incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapConstants.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedConstruct.java
      - copied, changed from r591310, incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java
Removed:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapConstants.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/BindingInfo.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapActionOutInterceptor.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/Messages.properties
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/BindingInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/BindingInfo.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/BindingInfo.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/BindingInfo.java Wed Nov  7 13:04:34 2007
@@ -146,6 +146,11 @@
         
         return null;
     }
+    
+    @Override
+    public String toString() {
+        return "[BindingInfo " + getBindingId() + "]";
+    }
 }
 
 

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConfiguration.java Wed Nov  7 13:04:34 2007
@@ -33,7 +33,7 @@
 
     @Override
     public String getBindingId() {
-        return "http://schemas.xmlsoap.org/soap/";
+        return SoapBindingConstants.SOAP11_BINDING_ID;
     }
 
     protected boolean isHeader(BindingOperationInfo op, MessagePartInfo part) {

Copied: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConstants.java (from r592846, incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapConstants.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConstants.java?p2=incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConstants.java&p1=incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapConstants.java&r1=592846&r2=592898&rev=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapConstants.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingConstants.java Wed Nov  7 13:04:34 2007
@@ -19,16 +19,14 @@
 
 package org.apache.cxf.binding.soap;
 
-public class SoapConstants {
+public class SoapBindingConstants {
     public static final String BINDING_STYLE_RPC = "rpc";
     public static final String BINDING_STYLE_DOC = "document";
     
     public static final String PARAMETER_STYLE_BARE = "bare";
     public static final String PARAMETER_STYLE_WRAPPED = "wrapped";
     
-//    public static final String STYLE_RPC = "rpc";
-//    public static final String STYLE_BARE = "bare";
-//    public static final String STYLE_WRAPPED = "wrapped";
     public static final String SOAP_ACTION = "SOAPAction";
-    public static final String BINDING_ID = null;
+    public static final String SOAP11_BINDING_ID = "http://schemas.xmlsoap.org/soap/";
+    public static final String SOAP12_BINDING_ID = "http://schemas.xmlsoap.org/wsdl/soap12/";
 }

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java Wed Nov  7 13:04:34 2007
@@ -302,8 +302,8 @@
         // TODO what about the mix style/use?
 
         // The default style should be doc-lit wrapped.
-        String parameterStyle = SoapConstants.PARAMETER_STYLE_WRAPPED;
-        String bindingStyle = SoapConstants.BINDING_STYLE_DOC;
+        String parameterStyle = SoapBindingConstants.PARAMETER_STYLE_WRAPPED;
+        String bindingStyle = SoapBindingConstants.BINDING_STYLE_DOC;
 
         org.apache.cxf.binding.soap.SoapBinding sb = null;
         SoapVersion version = null;
@@ -322,7 +322,7 @@
                     bindingStyle = sbi.getStyle(boi.getOperationInfo());
                 }
                 if (boi.getUnwrappedOperation() == null) {
-                    parameterStyle = SoapConstants.PARAMETER_STYLE_BARE;
+                    parameterStyle = SoapBindingConstants.PARAMETER_STYLE_BARE;
                 }
             }
         } else {
@@ -342,11 +342,11 @@
             sb.getOutInterceptors().add(new StaxOutInterceptor());
             sb.getOutInterceptors().add(new SoapHeaderOutFilterInterceptor());
 
-            if (SoapConstants.BINDING_STYLE_RPC.equalsIgnoreCase(bindingStyle)) {
+            if (SoapBindingConstants.BINDING_STYLE_RPC.equalsIgnoreCase(bindingStyle)) {
                 sb.getInInterceptors().add(new RPCInInterceptor());
                 sb.getOutInterceptors().add(new RPCOutInterceptor());
-            } else if (SoapConstants.BINDING_STYLE_DOC.equalsIgnoreCase(bindingStyle)
-                            && SoapConstants.PARAMETER_STYLE_BARE.equalsIgnoreCase(parameterStyle)) {
+            } else if (SoapBindingConstants.BINDING_STYLE_DOC.equalsIgnoreCase(bindingStyle)
+                            && SoapBindingConstants.PARAMETER_STYLE_BARE.equalsIgnoreCase(parameterStyle)) {
                 //sb.getInInterceptors().add(new BareInInterceptor());
                 sb.getInInterceptors().add(new DocLiteralInInterceptor());
                 sb.getOutInterceptors().add(new BareOutInterceptor());

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapActionOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapActionOutInterceptor.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapActionOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapActionOutInterceptor.java Wed Nov  7 13:04:34 2007
@@ -26,7 +26,7 @@
 
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.Soap12;
-import org.apache.cxf.binding.soap.SoapConstants;
+import org.apache.cxf.binding.soap.SoapBindingConstants;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.model.SoapOperationInfo;
 import org.apache.cxf.helpers.CastUtils;
@@ -83,7 +83,7 @@
 
     private String getSoapAction(SoapMessage message, BindingOperationInfo boi) {
         // allow an interceptor to override the SOAPAction if need be
-        String action = (String) message.get(SoapConstants.SOAP_ACTION);
+        String action = (String) message.get(SoapBindingConstants.SOAP_ACTION);
         
         // Fall back on the SOAPAction in the operation info
         if (action == null) {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java Wed Nov  7 13:04:34 2007
@@ -37,6 +37,7 @@
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.databinding.AegisServiceConfiguration;
 import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.soap.SoapBindingConstants;
 import org.apache.cxf.binding.soap.SoapBindingFactory;
 import org.apache.cxf.binding.soap.SoapTransportFactory;
 import org.apache.cxf.bus.extension.ExtensionManagerBus;
@@ -74,7 +75,7 @@
         SoapTransportFactory soapDF = new SoapTransportFactory();
         soapDF.setBus(bus);
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
-        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
+        dfm.registerDestinationFactory(SoapBindingConstants.SOAP11_BINDING_ID, soapDF);
         dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", soapDF);
         
         localTransport = new LocalTransportFactory();
@@ -87,7 +88,7 @@
         extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
         extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
         extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
-        extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/", localTransport);
+        extension.registerConduitInitiator(SoapBindingConstants.SOAP11_BINDING_ID, localTransport);
         
         bus.setExtension(new WSDLManagerImpl(), WSDLManager.class);
         

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxWsTest.java Wed Nov  7 13:04:34 2007
@@ -20,6 +20,7 @@
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.soap.SoapBindingConstants;
 import org.apache.cxf.binding.soap.SoapBindingFactory;
 import org.apache.cxf.binding.soap.SoapTransportFactory;
 import org.apache.cxf.test.AbstractCXFTest;
@@ -61,7 +62,7 @@
         SoapTransportFactory soapDF = new SoapTransportFactory();
         soapDF.setBus(bus);
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
-        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
+        dfm.registerDestinationFactory(SoapBindingConstants.SOAP11_BINDING_ID, soapDF);
         dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", soapDF);
         
         localTransport = new LocalTransportFactory();
@@ -74,7 +75,7 @@
         extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
         extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
         extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
-        extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/", localTransport);
+        extension.registerConduitInitiator(SoapBindingConstants.SOAP11_BINDING_ID, localTransport);
         
         WSDLManagerImpl manager = new WSDLManagerImpl();
         manager.setBus(bus);

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java Wed Nov  7 13:04:34 2007
@@ -36,7 +36,7 @@
  */
 public class JavascriptUtils {
     private static final String NL = "\n";
-    private StringBuffer code;
+    private StringBuilder code;
     private Stack<String> prefixStack;
     private String xmlStringAccumulatorVariable;
     private Map<String, String> defaultValueForSimpleType;
@@ -44,7 +44,7 @@
     private Set<String> intTypes;
     private Set<String> floatTypes;
     
-    public JavascriptUtils(StringBuffer code) {
+    public JavascriptUtils(StringBuilder code) {
         this.code = code;
         defaultValueForSimpleType = new HashMap<String, String>();
         defaultValueForSimpleType.put("int", "0");
@@ -183,5 +183,9 @@
         } else {
             return value;
         }
+    }
+    
+    public static String javaScriptNameToken(String token) {
+        return token;
     }
 }

Added: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties?rev=592898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties (added)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/Messages.properties Wed Nov  7 13:04:34 2007
@@ -0,0 +1,27 @@
+#
+#
+#    Licensed to the Apache Software Foundation (ASF) under one
+#    or more contributor license agreements. See the NOTICE file
+#    distributed with this work for additional information
+#    regarding copyright ownership. The ASF licenses this file
+#    to you under the Apache License, Version 2.0 (the
+#    "License"); you may not use this file except in compliance
+#    with the License. You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing,
+#    software distributed under the License is distributed on an
+#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#    KIND, either express or implied. See the License for the
+#    specific language governing permissions and limitations
+#    under the License.
+#
+#
+NON_SEQUENCE_PARTICLE=JavaScript limitation: Type {0} is not defined as a sequence. {1}
+NULL_PARTICLE=JavaScript limitation: Type {0} has no particle. {1} 
+NON_ELEMENT_CHILD=JavaScript limitation: Non-Element sequence member {0} of {1}. {2}
+ABSTRACT_ELEMENT=JavaScript limitation: Abstract element {0} of {1}. {2}
+ELEMENT_HAS_NO_TYPE= Element {0} has no type in the schema. {1}
+
+

Copied: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedConstruct.java (from r591310, incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedConstruct.java?p2=incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedConstruct.java&p1=incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java&r1=591310&r2=592898&rev=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedSchemaConstruct.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/UnsupportedConstruct.java Wed Nov  7 13:04:34 2007
@@ -24,24 +24,24 @@
  * This exception is thrown when the Javascript client generator hits a schema
  * construct that it cannot handle. 
  */
-public class UnsupportedSchemaConstruct extends RuntimeException {
+public class UnsupportedConstruct extends RuntimeException {
 
-    public UnsupportedSchemaConstruct() {
+    public UnsupportedConstruct() {
     }
 
-    public UnsupportedSchemaConstruct(String explanation) {
+    public UnsupportedConstruct(String explanation) {
         super(explanation);
     }
 
-    public UnsupportedSchemaConstruct(Throwable cause) {
+    public UnsupportedConstruct(Throwable cause) {
         super(cause);
     }
 
-    public UnsupportedSchemaConstruct(String explanation, Throwable cause) {
+    public UnsupportedConstruct(String explanation, Throwable cause) {
         super(explanation, cause);
     }
 
-    public UnsupportedSchemaConstruct(Message message) {
+    public UnsupportedConstruct(Message message) {
         super(message.toString());
     }
 

Added: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java?rev=592898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/XmlSchemaUtils.java Wed Nov  7 13:04:34 2007
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript;
+
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaType;
+
+/**
+ * 
+ */
+public final class XmlSchemaUtils {
+    
+    private static final Logger LOG = LogUtils.getL7dLogger(XmlSchemaUtils.class);
+    
+    private XmlSchemaUtils() {
+    }
+    
+    private static String cleanedUpSchemaSource(XmlSchemaType subject) {
+        if (subject.getSourceURI() == null) {
+            return "";
+        } else {
+            return subject.getSourceURI() + ":" + subject.getLineNumber(); 
+        }
+    }
+    
+    public static void unsupportedConstruct(String messageKey, XmlSchemaType subject) {
+        Message message = new Message(messageKey, LOG, subject.getQName(), 
+                                      cleanedUpSchemaSource(subject));
+        throw new UnsupportedConstruct(message);
+        
+    }
+    
+    public static void unsupportedConstruct(String messageKey, String what, XmlSchemaType subject) {
+        Message message = new Message(messageKey, LOG, what, subject.getQName(),
+                                      subject == null ? "(global)" 
+                                          : cleanedUpSchemaSource(subject));
+        LOG.severe(message.toString());
+        throw new UnsupportedConstruct(message);
+        
+    }
+
+    
+    public static XmlSchemaSequence getSequence(XmlSchemaComplexType type) {
+        XmlSchemaParticle particle = type.getParticle();
+        XmlSchemaSequence sequence = null;
+        
+        if (particle == null) {
+            unsupportedConstruct("NULL_PARTICLE", type);
+        }
+        
+        try {
+            sequence = (XmlSchemaSequence) particle;
+        } catch (ClassCastException cce) {
+            unsupportedConstruct("NON_SEQUENCE_PARTICLE", type);
+        }
+        
+        return sequence;
+    }
+    
+    /**
+     * This copes with an observed phenomenon in the schema built by the ReflectionServiceFactoryBean. It 
+     * is creating element such that: (a) the type is not set. (b) the refName is set. 
+     * (c) the namespaceURI in the refName is set empty. This apparently indicates 
+     * 'same Schema' to everyone else, so thus function implements
+     * that convention here. It is unclear if that is a correct structure, 
+     * and it if changes, we can simplify or eliminate this function.
+     * @param name
+     * @param referencingURI
+     * @return
+     */
+    public static XmlSchemaElement findElementByRefName(XmlSchemaCollection xmlSchemaCollection,
+                                                         QName name, 
+                                                         String referencingURI) {
+        String uri = name.getNamespaceURI();
+        if ("".equals(uri)) {
+            uri = referencingURI;
+        }
+        QName copyName = new QName(uri, name.getLocalPart());
+        XmlSchemaElement target = xmlSchemaCollection.getElementByQName(copyName);
+        assert target != null;
+        return target;
+    }
+    
+    
+    /**
+     * Follow a chain of references from element to element until we can obtain a type.
+     * @param element
+     * @return
+     */
+    public static XmlSchemaType getElementType(XmlSchemaCollection xmlSchemaCollection,
+                                               String referencingURI, 
+                                               XmlSchemaElement element,
+                                               XmlSchemaType containingType) {
+        if (referencingURI == null && containingType != null) {
+            referencingURI = containingType.getQName().getNamespaceURI();
+        }
+        XmlSchemaElement originalElement = element;
+        while (element.getSchemaType() == null && element.getRefName() != null) {
+            XmlSchemaElement nextElement = findElementByRefName(xmlSchemaCollection,
+                                                                element.getRefName(), 
+                                                                referencingURI);
+            assert nextElement != null;
+            element = nextElement;
+        }
+        if (element.getSchemaType() == null) {
+            XmlSchemaUtils.unsupportedConstruct("ELEMENT_HAS_NO_TYPE", originalElement.getName(), 
+                                                containingType);
+        }
+        return element.getSchemaType();
+    }
+
+}

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java Wed Nov  7 13:04:34 2007
@@ -19,15 +19,23 @@
 
 package org.apache.cxf.javascript.service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.logging.Logger;
 
+import org.apache.cxf.binding.soap.SoapBindingConstants;
 import org.apache.cxf.binding.soap.model.SoapBindingInfo;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.javascript.BasicNameManager;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.javascript.JavascriptUtils;
 import org.apache.cxf.javascript.NameManager;
-import org.apache.cxf.javascript.UnsupportedSchemaConstruct;
+import org.apache.cxf.javascript.UnsupportedConstruct;
+import org.apache.cxf.javascript.XmlSchemaUtils;
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.FaultInfo;
@@ -36,23 +44,32 @@
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.local.LocalTransportFactory;
 import org.apache.cxf.wsdl.WSDLConstants;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
 
-public class ServiceJavascriptBuilder extends ServiceModelVisitor {
+class ServiceJavascriptBuilder extends ServiceModelVisitor {
     private static final Logger LOG = LogUtils.getL7dLogger(ServiceJavascriptBuilder.class);
 
     private boolean isRPC;
-    private boolean isWrapped;
     private SoapBindingInfo soapBindingInfo;
     private JavascriptUtils utils;
     private NameManager nameManager;
-    private StringBuffer code;
+    private StringBuilder code;
+    private String currentInterfaceClassName;
+    private Set<OperationInfo> operationsWithNameConflicts;
+    private XmlSchemaCollection xmlSchemaCollection;
 
-    public ServiceJavascriptBuilder(ServiceInfo serviceInfo) {
+    public ServiceJavascriptBuilder(ServiceInfo serviceInfo, NameManager nameManager) {
         super(serviceInfo);
-        code = new StringBuffer();
+        code = new StringBuilder();
         utils = new JavascriptUtils(code);
-        nameManager = new BasicNameManager(serviceInfo);
+        this.nameManager = nameManager;
+        xmlSchemaCollection = serviceInfo.getXmlSchemaCollection();
     }
 
     @Override
@@ -61,9 +78,19 @@
 
     @Override
     public void begin(InterfaceInfo intf) {
-        utils.appendLine("function " 
-                         + nameManager.getJavascriptName(intf.getName())
-                         + " () {");
+        currentInterfaceClassName = nameManager.getJavascriptName(intf.getName());
+        operationsWithNameConflicts = new HashSet<OperationInfo>();
+        utils.appendLine("function " + currentInterfaceClassName + " () {");
+        utils.appendLine("}");
+        Map<String, OperationInfo> localNameMap = new HashMap<String, OperationInfo>();
+        for (OperationInfo operation : intf.getOperations()) {
+            OperationInfo conflict = localNameMap.get(operation.getName().getLocalPart());
+            if (conflict != null) {
+                operationsWithNameConflicts.add(conflict);
+                operationsWithNameConflicts.add(operation);
+            }
+            localNameMap.put(operation.getName().getLocalPart(), operation);
+        }
     }
 
     @Override
@@ -76,20 +103,97 @@
 
     @Override
     public void begin(OperationInfo op) {
-        isWrapped = !op.isUnwrappedCapable();
+        assert !isRPC;
+        boolean isWrapped = op.isUnwrappedCapable();
+        // to make best use of the visitor scheme, we wait until end to
+        // create the function, since the message function can participate in
+        // building the argument list.
+        boolean needsLongName = operationsWithNameConflicts.contains(op);
+        String opFunctionName;
+        if (needsLongName) {
+            opFunctionName = nameManager.getJavascriptName(op.getName());
+        } else {
+            opFunctionName = JavascriptUtils.javaScriptNameToken(op.getName().getLocalPart());
+        }
+        List<String> inputParameterNames = new ArrayList<String>();
+        MessageInfo inputMessage = op.getInput();
+        String wrapperClassName = null;
+        StringBuilder parameterList = new StringBuilder();
+        XmlSchemaElement wrapperElement = null;
+
+        if (inputMessage != null) {
+            List<MessagePartInfo> parts = inputMessage.getMessageParts();
+            if (isWrapped) {
+                // expect one input part.
+                assert parts.size() == 1;
+                MessagePartInfo wrapperPart = parts.get(0);
+                // we expect a type
+                assert wrapperPart.isElement();
+                wrapperElement = (XmlSchemaElement)wrapperPart.getXmlSchema();
+                XmlSchemaComplexType wrapperType = 
+                    (XmlSchemaComplexType)XmlSchemaUtils.getElementType(xmlSchemaCollection, 
+                                                                        op.getName().getNamespaceURI(), 
+                                                                        wrapperElement,
+                                                                        null);
+                wrapperClassName = nameManager.getJavascriptName(wrapperType);
+                XmlSchemaSequence wrapperTypeSequence = XmlSchemaUtils.getSequence(wrapperType);
+                for (int i = 0; i < wrapperTypeSequence.getItems().getCount(); i++) {
+                    XmlSchemaObject thing = wrapperTypeSequence.getItems().getItem(i);
+                    if (!(thing instanceof XmlSchemaElement)) {
+                        XmlSchemaUtils.unsupportedConstruct("NON_ELEMENT_CHILD", thing.getClass()
+                            .getSimpleName(), wrapperType);
+                    }
+
+                    XmlSchemaElement elChild = (XmlSchemaElement)thing;
+                    inputParameterNames.add(elChild.getName());
+                }
+            }
+
+            for (String param : inputParameterNames) {
+                parameterList.append(param);
+                parameterList.append(", ");
+            }
+        }
+
+        // note that these functions operate in terms of async callbacks, they
+        // don't
+        // ever have return values. Hypothetically, I suppose that users who
+        // wanted a
+        // synchronous behavior might want a synchronous function (rather like
+        // the Microsoft
+        // wsdl.exe behavior), but I'm not going to worry about it for now.
+        utils.appendLine("function " + opFunctionName + "(" + parameterList
+                         + "responseCallback, errorCallback) {");
+        
+        // wrapped
+        if (wrapperClassName != null) {
+            utils.appendLine("var wrapper = new " + wrapperClassName + "();");
+            for (String param : inputParameterNames) {
+                utils.appendLine("wrapper.set" + StringUtils.capitalize(param) + "(" + param + ");");
+            }
+        }
+
+        utils.appendLine("}");
+    }
+
+    @Override
+    public void end(OperationInfo op) {
     }
 
     @Override
     public void begin(ServiceInfo service) {
-        // assume only one soap binding. 
+        // assume only one soap binding.
         // until further consideration.
-        // hypothetically, we could generate two different JavaScript classes, one for each.
+        // hypothetically, we could generate two different JavaScript classes,
+        // one for each.
         for (BindingInfo bindingInfo : service.getBindings()) {
-            if (WSDLConstants.NS_SOAP11.equals(bindingInfo.getBindingId())
-                || WSDLConstants.NS_SOAP12.equals(bindingInfo.getBindingId())) { 
+            if (SoapBindingConstants.SOAP11_BINDING_ID.equals(bindingInfo.getBindingId())
+                || SoapBindingConstants.SOAP11_BINDING_ID.equals(bindingInfo.getBindingId())) {
                 SoapBindingInfo sbi = (SoapBindingInfo)bindingInfo;
                 if (WSDLConstants.NS_SOAP11_HTTP_TRANSPORT.equals(sbi.getTransportURI())
-                    || WSDLConstants.NS_SOAP12_HTTP_TRANSPORT.equals(sbi.getTransportURI())) {
+                    || WSDLConstants.NS_SOAP12_HTTP_TRANSPORT.equals(sbi.getTransportURI())
+                    // we may want this for testing.
+                    || LocalTransportFactory.TRANSPORT_ID.equals(sbi.getTransportURI())) {
                     soapBindingInfo = sbi;
                     break;
                 }
@@ -98,7 +202,7 @@
         if (soapBindingInfo == null) {
             unsupportedConstruct("NO_SOAP_BINDING", service.getName());
         }
-        
+
         isRPC = soapBindingInfo.getStyle().equals(WSDLConstants.RPC);
     }
 
@@ -121,41 +225,9 @@
     @Override
     public void end(ServiceInfo service) {
     }
-    
+
     private void unsupportedConstruct(String messageKey, Object... args) {
         Message message = new Message(messageKey, LOG, args);
-        throw new UnsupportedSchemaConstruct(message);
-    }
-
-    public boolean isRPC() {
-        return isRPC;
-    }
-
-    public void setRPC(boolean rpc) {
-        this.isRPC = rpc;
-    }
-
-    public boolean isWrapped() {
-        return isWrapped;
-    }
-
-    public void setWrapped(boolean wrapped) {
-        this.isWrapped = wrapped;
-    }
-
-    public JavascriptUtils getUtils() {
-        return utils;
-    }
-
-    public void setUtils(JavascriptUtils utils) {
-        this.utils = utils;
-    }
-
-    public NameManager getNameManager() {
-        return nameManager;
-    }
-
-    public void setNameManager(NameManager nameManager) {
-        this.nameManager = nameManager;
+        throw new UnsupportedConstruct(message);
     }
 }

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/Messages.properties?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/Messages.properties (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/Messages.properties Wed Nov  7 13:04:34 2007
@@ -18,8 +18,3 @@
 #    under the License.
 #
 #
-NON_ELEMENT_CHILD=JavaScript limitation: Non-Element sequence member {0} of {1}. {2}
-NON_SEQUENCE_PARTICLE=JavaScript limitation: Type {0} is not defined as a sequence. {1}
-ABSTRACT_ELEMENT=JavaScript limitation: Abstract element {0} of {1}. {2}
-NULL_PARTICLE=JavaScript limitation: Type {0} has no particle. {1} 
-ELEMENT_HAS_NO_TYPE= Element {0} has no type in the schema. {1}

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=592898&r1=592897&r2=592898&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java (original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java Wed Nov  7 13:04:34 2007
@@ -24,16 +24,14 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.javascript.JavascriptUtils;
 import org.apache.cxf.javascript.NameManager;
-import org.apache.cxf.javascript.UnsupportedSchemaConstruct;
+import org.apache.cxf.javascript.UnsupportedConstruct;
+import org.apache.cxf.javascript.XmlSchemaUtils;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.wsdl.WSDLConstants;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
@@ -54,7 +52,7 @@
  */
 public class SchemaJavascriptBuilder {
     
-    private static final Logger LOG = LogUtils.getL7dLogger(SchemaJavascriptBuilder.class);
+    //private static final Logger LOG = LogUtils.getL7dLogger(SchemaJavascriptBuilder.class);
     
     private static final XmlSchemaForm QUALIFIED = new XmlSchemaForm(XmlSchemaForm.QUALIFIED);
     private static final XmlSchemaForm UNQUALIFIED = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
@@ -100,29 +98,6 @@
         }
     }
     
-    private String cleanedUpSchemaSource(XmlSchemaType subject) {
-        if (subject.getSourceURI() == null) {
-            return "";
-        } else {
-            return subject.getSourceURI() + ":" + subject.getLineNumber(); 
-        }
-    }
-    
-    private void unsupportedConstruct(String messageKey, XmlSchemaType subject) {
-        Message message = new Message(messageKey, LOG, subject.getQName(), 
-                                      cleanedUpSchemaSource(subject));
-        throw new UnsupportedSchemaConstruct(message);
-        
-    }
-    
-    private void unsupportedConstruct(String messageKey, String what, XmlSchemaType subject) {
-        Message message = new Message(messageKey, LOG, what, subject.getQName(), 
-                                      cleanedUpSchemaSource(subject));
-        LOG.severe(message.toString());
-        throw new UnsupportedSchemaConstruct(message);
-        
-    }
-    
     public static boolean isParticleArray(XmlSchemaParticle particle) {
         return particle.getMaxOccurs() > 1;
     }
@@ -220,7 +195,7 @@
                     code.append(complexTypeConstructorAndAccessors(complexType));
                     code.append(complexTypeSerializerFunction(complexType));
                     code.append(domDeserializerFunction(complexType));
-                } catch (UnsupportedSchemaConstruct usc) {
+                } catch (UnsupportedConstruct usc) {
                     continue; // it could be empty, but the style checker would complain.
                 }
             }
@@ -229,39 +204,32 @@
         return code.toString();
     }
     
+    
+    
     public String complexTypeConstructorAndAccessors(XmlSchemaComplexType type) {
-        StringBuffer code = new StringBuffer();
-        StringBuffer accessors = new StringBuffer();
+        StringBuilder code = new StringBuilder();
+        StringBuilder accessors = new StringBuilder();
         JavascriptUtils utils = new JavascriptUtils(code);
-        XmlSchemaParticle particle = type.getParticle();
-        XmlSchemaSequence sequence = null;
+        XmlSchemaSequence sequence = XmlSchemaUtils.getSequence(type);
+        
         final String elementPrefix = "this._";
         
         String typeObjectName = nameManager.getJavascriptName(type);
         code.append("function " + typeObjectName + " () {\n");
         
-        if (particle == null) {
-            unsupportedConstruct("NULL_PARTICLE", type);
-        }
-        
-        try {
-            sequence = (XmlSchemaSequence) particle;
-        } catch (ClassCastException cce) {
-            unsupportedConstruct("NON_SEQUENCE_PARTICLE", type);
-        }
-        
         for (int i = 0; i < sequence.getItems().getCount(); i++) {
             XmlSchemaObject thing = sequence.getItems().getItem(i);
             if (!(thing instanceof XmlSchemaElement)) {
-                unsupportedConstruct("NON_ELEMENT_CHILD", thing.getClass().getSimpleName(), type);
+                XmlSchemaUtils.unsupportedConstruct("NON_ELEMENT_CHILD", 
+                                                    thing.getClass().getSimpleName(), type);
             }
             
             XmlSchemaElement elChild = (XmlSchemaElement)thing;
-            XmlSchemaType elType = getElementType(type, elChild);
+            XmlSchemaType elType = XmlSchemaUtils.getElementType(xmlSchemaCollection, null, elChild, type);
 
             boolean nillable = elChild.isNillable();
             if (elChild.isAbstract()) { 
-                unsupportedConstruct("ABSTRACT_ELEMENT", elChild.getName(), type);
+                XmlSchemaUtils.unsupportedConstruct("ABSTRACT_ELEMENT", elChild.getName(), type);
             }
             
             // Assume that no lunatic has created multiple elements that differ only by namespace.
@@ -302,46 +270,7 @@
         return code.toString() + "\n" + accessors.toString();
     }
     
-    /**
-     * This copes with an observed phenomenon in the schema built by the ReflectionServiceFactoryBean. It 
-     * is creating element such that: (a) the type is not set. (b) the refName is set. 
-     * (c) the namespaceURI in the refName is set empty. This apparently indicates 
-     * 'same Schema' to everyone else, so thus function implements
-     * that convention here. It is unclear if that is a correct structure, 
-     * and it if changes, we can simplify or eliminate this function.
-     * @param name
-     * @param referencingURI
-     * @return
-     */
-    private XmlSchemaElement findElementByRefName(QName name, String referencingURI) {
-        String uri = name.getNamespaceURI();
-        if ("".equals(uri)) {
-            uri = referencingURI;
-        }
-        QName copyName = new QName(uri, name.getLocalPart());
-        XmlSchemaElement target = xmlSchemaCollection.getElementByQName(copyName);
-        assert target != null;
-        return target;
-    }
     
-    /**
-     * Follow a chain of references from element to element until we can obtain a type.
-     * @param element
-     * @return
-     */
-    private XmlSchemaType getElementType(XmlSchemaComplexType containingType, XmlSchemaElement element) {
-        XmlSchemaElement originalElement = element;
-        while (element.getSchemaType() == null && element.getRefName() != null) {
-            XmlSchemaElement nextElement = findElementByRefName(element.getRefName(), 
-                                                                containingType.getQName().getNamespaceURI());
-            assert nextElement != null;
-            element = nextElement;
-        }
-        if (element.getSchemaType() == null) {
-            unsupportedConstruct("ELEMENT_HAS_NO_TYPE", originalElement.getName(), containingType);
-        }
-        return element.getSchemaType();
-    }
 
     /**
      * Produce a serializer function for a type.
@@ -353,14 +282,14 @@
      */
     public String complexTypeSerializerFunction(XmlSchemaComplexType type) {
         
-        StringBuffer bodyCode = new StringBuffer();
+        StringBuilder bodyCode = new StringBuilder();
         JavascriptUtils bodyUtils = new JavascriptUtils(bodyCode);
         bodyUtils.setXmlStringAccumulator("xml");
 
         NamespacePrefixAccumulator prefixAccumulator = new NamespacePrefixAccumulator();
         complexTypeSerializerBody(type, "this._", bodyUtils, prefixAccumulator);
         
-        StringBuffer code = new StringBuffer();
+        StringBuilder code = new StringBuilder();
         JavascriptUtils utils = new JavascriptUtils(code);
         String functionName = nameManager.getJavascriptName(type) + "_" + "serialize";
         code.append("function " + functionName + "(cxfjsutils, elementName) {\n");
@@ -404,17 +333,15 @@
                                           JavascriptUtils utils, 
                                           NamespacePrefixAccumulator prefixAccumulator) {
 
-        XmlSchemaParticle particle = type.getParticle();
-        XmlSchemaSequence sequence = null;
-        sequence = (XmlSchemaSequence) particle;
+        XmlSchemaSequence sequence = XmlSchemaUtils.getSequence(type);
 
         // XML Schema, please meet Iterable (not).
         for (int i = 0; i < sequence.getItems().getCount(); i++) {
             XmlSchemaElement elChild = (XmlSchemaElement)sequence.getItems().getItem(i);
-            XmlSchemaType elType = getElementType(type, elChild);
+            XmlSchemaType elType = XmlSchemaUtils.getElementType(xmlSchemaCollection, null, elChild, type);
             boolean nillable = elChild.isNillable();
             if (elChild.isAbstract()) {
-                unsupportedConstruct("ABSTRACT_ELEMENT", elChild.getName(), type);
+                XmlSchemaUtils.unsupportedConstruct("ABSTRACT_ELEMENT", elChild.getName(), type);
             }
             
             // assume that no lunatic has created multiple elements that differ only by namespace.
@@ -495,19 +422,19 @@
      * @return the string contents of the JavaScript.
      */
     public String domDeserializerFunction(XmlSchemaComplexType type) {
-        StringBuffer code = new StringBuffer();
+        StringBuilder code = new StringBuilder();
         JavascriptUtils utils = new JavascriptUtils(code);
         XmlSchemaParticle particle = type.getParticle();
         XmlSchemaSequence sequence = null;
         
         if (particle == null) {
-            unsupportedConstruct("NULL_PARTICLE", type);
+            XmlSchemaUtils.unsupportedConstruct("NULL_PARTICLE", type);
         }
         
         try {
             sequence = (XmlSchemaSequence) particle;
         } catch (ClassCastException cce) {
-            unsupportedConstruct("NON_SEQUENCE_PARTICLE", type);
+            XmlSchemaUtils.unsupportedConstruct("NON_SEQUENCE_PARTICLE", type);
         }
         
         String typeObjectName = nameManager.getJavascriptName(type);
@@ -522,11 +449,12 @@
             utils.appendLine("cxfjsutils.trace('curElement: ' + cxfjsutils.traceElementName(curElement));");
             XmlSchemaObject thing = sequence.getItems().getItem(i);
             if (!(thing instanceof XmlSchemaElement)) {
-                unsupportedConstruct("NON_ELEMENT_CHILD", thing.getClass().getSimpleName(), type);
+                XmlSchemaUtils.unsupportedConstruct("NON_ELEMENT_CHILD", 
+                                                    thing.getClass().getSimpleName(), type);
             }
             
             XmlSchemaElement elChild = (XmlSchemaElement)thing;
-            XmlSchemaType elType = getElementType(type, elChild);
+            XmlSchemaType elType = XmlSchemaUtils.getElementType(xmlSchemaCollection, null, elChild, type);
             boolean simple = elType instanceof XmlSchemaSimpleType;
 
             String accessorName = "set" + StringUtils.capitalize(elChild.getName()); 

Added: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java?rev=592898&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java (added)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/service/DocLitWrappedTest.java Wed Nov  7 13:04:34 2007
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.javascript.service;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.javascript.BasicNameManager;
+import org.apache.cxf.javascript.JavascriptTestUtilities;
+import org.apache.cxf.javascript.NameManager;
+import org.apache.cxf.javascript.types.SchemaJavascriptBuilder;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.junit.Test;
+import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
+
+public class DocLitWrappedTest extends AbstractDependencyInjectionSpringContextTests {
+    private JavascriptTestUtilities testUtilities;
+    private Client client;
+    private List<ServiceInfo> serviceInfos;
+    private Collection<SchemaInfo> schemata;
+    private NameManager nameManager;
+    private JaxWsProxyFactoryBean clientProxyFactory;
+
+    public DocLitWrappedTest() {
+        testUtilities = new JavascriptTestUtilities(getClass());
+        testUtilities.addDefaultNamespaces();
+    }
+
+    @Override
+    protected String[] getConfigLocations() {
+        return new String[] {"classpath:serializationTestBeans.xml"};
+    }
+
+    @Test 
+    public void testDeserialization() throws Exception {
+        setupClientAndRhino("simple-dlwu-proxy-factory");
+        testUtilities.readResourceIntoRhino("/deserializationTests.js");
+        DataBinding dataBinding = clientProxyFactory.getServiceFactory().getDataBinding();
+        assertNotNull(dataBinding);
+    }
+
+    private void setupClientAndRhino(String clientProxyFactoryBeanId) throws IOException {
+        testUtilities.setBus((Bus)applicationContext.getBean("cxf"));
+        
+        testUtilities.initializeRhino();
+        testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/cxf-utils.js");
+
+        clientProxyFactory = (JaxWsProxyFactoryBean)applicationContext.getBean(clientProxyFactoryBeanId);
+        client = clientProxyFactory.getClientFactoryBean().create();
+        serviceInfos = client.getEndpoint().getService().getServiceInfos();
+        // there can only be one.
+        assertEquals(1, serviceInfos.size());
+        ServiceInfo serviceInfo = serviceInfos.get(0);
+        schemata = serviceInfo.getSchemas();
+        nameManager = new BasicNameManager(serviceInfo);
+        for (SchemaInfo schema : schemata) {
+            SchemaJavascriptBuilder builder = 
+                new SchemaJavascriptBuilder(serviceInfo.getXmlSchemaCollection(), nameManager, schema);
+            String allThatJavascript = builder.generateCodeForSchema(schema);
+            assertNotNull(allThatJavascript);
+            testUtilities.readStringIntoRhino(allThatJavascript, schema.toString() + ".js");
+        }
+        
+        ServiceJavascriptBuilder serviceBuilder = 
+            new ServiceJavascriptBuilder(serviceInfo, nameManager);
+        serviceBuilder.walk();
+    }
+}