Author: jonathan
Date: Tue Dec 18 14:45:58 2007
New Revision: 11428

Log:

MASHUP-441
Endpoint fixup improvements - also sets the default endpoint to an https 
endpoint if that's where the page domain is.
Removed redundant fixup from tryit.xslt

Modified:
   trunk/commons/dynamic-codegen/src/jsstub.xslt
   trunk/commons/dynamic-codegen/src/tryit.xslt

Modified: trunk/commons/dynamic-codegen/src/jsstub.xslt
==============================================================================
--- trunk/commons/dynamic-codegen/src/jsstub.xslt       (original)
+++ trunk/commons/dynamic-codegen/src/jsstub.xslt       Tue Dec 18 14:45:58 2007
@@ -311,7 +311,12 @@
     var extractedValue = element.*.toString();
     var resultValue, i;
     var js = new Namespace("http://www.wso2.org/ns/jstype";);
-    switch ([EMAIL PROTECTED]::type.toString()) {
+    var type = [EMAIL PROTECTED]::type;
+    if (type == null) {
+        type = "xml";
+    } else {
+        type = type.toString();
+    }switch (type) {
         case "string":
             return extractedValue;
             break;
@@ -353,7 +358,13 @@
     if (element == null) return "";
     var extractedValue = WSRequest.util._stringValue(element);
     var resultValue, i;
-    switch (element.getAttribute("js:type").toString()) {
+    var type = element.getAttribute("js:type");
+    if (type == null) {
+        type = "xml";
+    } else {
+        type = type.toString();
+    }
+    switch (type) {
         case "string":
             return extractedValue;
             break;
@@ -496,19 +507,26 @@
 domainNoPort.visible = false;
 
 try {
+    var secureEndpoint = "";
     var pageUrl = document.URL;
     var pageScheme = scheme(pageUrl);
     // only attempt fixup if we're from an http/https domain ('file:' works 
fine on IE without fixup)
     if (pageScheme == "http" || pageScheme == "https") {
         var pageDomain = domain(pageUrl);
         var pageDomainNoPort = domainNoPort(pageUrl);
-        if (pageDomainNoPort.indexOf('localhost') == 0 ||
-            pageDomainNoPort.indexOf('127.0.0.1') == 0 ) {
-            
-            var endpoints = <xsl:value-of 
select="$service-name"/>._endpointDetails;
-            for (var i in endpoints) {
-                var address = endpoints[i].address;
-                endpoints[i].address = address.replace(domainNoPort(address), 
pageDomainNoPort);
+        var endpoints = <xsl:value-of 
select="$service-name"/>._endpointDetails;
+        // loop through each available endpoint
+        for (var i in endpoints) {
+            var address = endpoints[i].address;
+            // if we're in a secure domain, set the endpoint to the first 
secure endpoint we come across
+            if (secureEndpoint == "" &amp;&amp; pageScheme == "https" 
&amp;&amp; scheme(address) == "https") {
+                secureEndpoint = i;
+                <xsl:value-of select="$service-name"/>.endpoint=secureEndpoint;
+            }
+            // if we're in a known localhost domain, rewrite the endpoint 
domain so that we won't get
+            //  a bogus xss violation
+            if (pageDomainNoPort.indexOf('localhost') == 0 || 
pageDomainNoPort.indexOf('127.0.0.1') == 0 ) {
+                    endpoints[i].address = 
address.replace(domainNoPort(address), pageDomainNoPort);
             }
         }
     }

Modified: trunk/commons/dynamic-codegen/src/tryit.xslt
==============================================================================
--- trunk/commons/dynamic-codegen/src/tryit.xslt        (original)
+++ trunk/commons/dynamic-codegen/src/tryit.xslt        Tue Dec 18 14:45:58 2007
@@ -407,12 +407,6 @@
                     }
                     // and remove access to this endpoint from this page.
                     endpointName.removeChild(endpointName.options[i]);
-                } else {
-                    if (domain(endpointAddress) != pageDomain) {
-                        // replace the endpoints domain with this one.
-                        var newAddress = 
endpointAddress.replace(domain(endpointAddress), pageDomain);
-                        <xsl:value-of 
select="$service-name"/>.setAddress(endpointName.options[i].value, newAddress)
-                    }
                 }
             }
         }
@@ -767,12 +761,12 @@
                                     <xsl:variable name="prefix">
                                         <xsl:if test="@type-namespace = 
'http://www.w3.org/2001/XMLSchema'">xs:</xsl:if>
                                     </xsl:variable>
-                                    <xsl:variable name="restriction">
-                                        <xsl:if test="@restriction-of">
+                                    <xsl:variable name="restriction">
+                                        <xsl:if test="@restriction-of">
                                             <xsl:if 
test="@restriction-namespace = 'http://www.w3.org/2001/XMLSchema'">xs:</xsl:if>
                                             <xsl:value-of 
select="@restriction-of"/>
-                                            <xsl:text> restriction</xsl:text>  
                                          
-                                        </xsl:if>
+                                            <xsl:text> restriction</xsl:text>  
                                          
+                                        </xsl:if>
                                     </xsl:variable>
                                     <td class="label"><div>
                                         <xsl:value-of select="@name"/>

_______________________________________________
Commons-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commons-dev

Reply via email to