Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Connie DeCinko 931 posts 1160 karma points
    Jun 14, 2011 @ 18:47
    Connie DeCinko
    0

    How to call .NET web service inside Javascript within XSLT

    I've got some XSLT that contains Javascript.  I need to pass one of the Javascript variables to a webservice.  I've seen messages say, oh yeah, it can be done, but no code examples.

    How can I call a webservice AND pass it a value?

     

  • Connie DeCinko 931 posts 1160 karma points
    Jun 14, 2011 @ 19:24
    Connie DeCinko
    0

    Here is my XSLT, where you can see where I need to pass the value.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:Designit.VideoEmbed="urn:Designit.VideoEmbed" xmlns:ucomponents.cms="urn:ucomponents.cms" xmlns:ucomponents.dates="urn:ucomponents.dates" xmlns:ucomponents.io="urn:ucomponents.io" xmlns:ucomponents.media="urn:ucomponents.media" xmlns:ucomponents.members="urn:ucomponents.members" xmlns:ucomponents.nodes="urn:ucomponents.nodes" xmlns:ucomponents.search="urn:ucomponents.search" xmlns:ucomponents.strings="urn:ucomponents.strings" xmlns:ucomponents.urls="urn:ucomponents.urls" xmlns:ucomponents.xml="urn:ucomponents.xml" xmlns:PS.XSLTsearch="urn:PS.XSLTsearch"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets Designit.VideoEmbed ucomponents.cms ucomponents.dates ucomponents.io ucomponents.media ucomponents.members ucomponents.nodes ucomponents.search ucomponents.strings ucomponents.urls ucomponents.xml PS.XSLTsearch ">


    <xsl:output method="html" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

      <xsl:if test="$currentPage/ancestor-or-self::* [activeMenu = 'Lawyers' or @id=1672]">
        <script type="text/javascript" src="/js/jquery.ba-postmessage.min.js"></script>
        <script type="text/javascript">
          $(function(){
     
            // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
            // passed via query string or hard coded into the child page, it depends on your needs).
            var src = 'http://<xsl:value-of select="umbraco.library:Replace(umbraco.library:RequestServerVariables('SERVER_NAME'),'.azbar.','.myazbar.')" />/includes/logInOut_btn_iFramed.cfm#' + encodeURIComponent(document.location.href),
          // Append the Iframe into the DOM.
          iframe = $('<iframe src="' + src + '" name="logInOut_btn_iframe" id="logInOut_btn_iframe" width="200" height="32" frameborder="0" allowtransparency="yes" marginheight="0"
          marginwidth="0" scrolling="no" class="btn-login-iFrame"></iframe>')
            .appendTo('#theIFrame');
          
          // Setup a callback to handle the dispatched MessageEvent event. In cases where
          // window.postMessage is supported, the passed event will have .data, .origin and
          // .source properties. Otherwise, this will only have the .data property.
          $.receiveMessage(function(e){
        
          alert("XSLT: " + e.data);
          
          if (e.data=="loggedIn=yes") {
            isLoggedIn = "Yes";
          }
          else if (e.data == "loggedIn=no") {
            isLoggedIn = "No";
          }
          
          // ***** SEND isLoggedIn VALUE TO WEB SERVICE
          //SBA.AZBar.UserControls.SetLoggedInStatus.setStatus(isLoggedIn);
        
            // An optional origin URL (Ignored where window.postMessage is unsupported).
          }, 'http://<xsl:value-of select="umbraco.library:Replace(umbraco.library:RequestServerVariables('SERVER_NAME'),'.azbar.','.myazbar.')" />' );
        
          });
        </script>
      </xsl:if>
      
      <span id="theIFrame"></span>

    </xsl:template>

    </xsl:stylesheet>

     

Please Sign in or register to post replies

Write your reply to:

Draft