Transforming a SOAP result with a XSL using 'Javascript Soap Client'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Peterson Chaves
    New Member
    • Jun 2011
    • 1

    Transforming a SOAP result with a XSL using 'Javascript Soap Client'

    Hi,

    I have an WebService (.net 3.5) with Soap 1.1 method. I am using ASP 3 (classic) with Javascript Soap Client to call the WebService and I need to transform the result with a XSL file, but i don´t know how to do this with a SOAP 1.1. I have some solutions with a default XML results.

    XML Result:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <soap:Body>
        <KYRHResponse>
          <KYRHResult>
            <KYRH xmlns="">
              <Informativo>
                <Status>OK</Status>
                <MsgErro></MsgErro>
                <QtdRegistros>15</QtdRegistros>
              </Informativo>
              <Cabecalho>
                <Item>
                  <NomeBanco>xxxxx</NomeBanco>
                  <Cabec>AGENCIA: xxxxx CONTA: xxxxx</Cabec>
                  <DataRef>21/06/11</DataRef>
                  <Cabec1>VCTO CRT  N.NUMERO  DEP.         VALOR     - SACADO (CGC E NOME) -  OBSERVACAO</Cabec1>
                </Item>
              </Cabecalho>
              <Dados>
                <Item>
                  <Venc>01/07</Venc>
                  <Carteira>112</Carteira>
                  <NossoNum>12121212</NossoNum>
                  <DacNossoNum>4</DacNossoNum>
                  <Depos>2861</Depos>
                  <Valor>1.316,27</Valor>
                  <BR></BR>
                  <CGC>11111111</CGC>
                  <Nome>xxxx xxxxxx</Nome>
                  <Obs></Obs>
                </Item>
              </Dados>
            </KYRH>
          </KYRHResult>
        </KYRHResponse>
      </soap:Body>
    </soap:Envelope>
    XSL file:

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:template match="/">
    
        <table border="1" cellpadding="2" padding="2">
    
          <xsl:if test="/*/*/*/*/*/*/Informativo/Status = 'OK'">
    
            <xsl:if test="/*//Informativo/QtdRegistros != 0">
              <xsl:call-template name="OK_REGISTROS" />
            </xsl:if>
    
            <xsl:if test="/*/Informativo/QtdRegistros = 0">
              <xsl:call-template name="NOK_REGISTROS" />
            </xsl:if>
    
          </xsl:if>
    
          <xsl:if test="/*/Informativo/Status = 'Erro'">
            <xsl:call-template name="NOK"/>
          </xsl:if>
    
        </table>
    
      </xsl:template>
    
      <xsl:template name="NOK">
        <tr>
          <td colspan="8">
            Erro: <xsl:value-of select="/*/Informativo/MsgErro"/>
          </td>
        </tr>
      </xsl:template>
    
      <xsl:template name="OK_REGISTROS">
    
        <xsl:if test="/*/Informativo/QtdRegistros > 0">
          <tr>
            <td colspan="8">
              <hr />
            </td>
          </tr>
          <tr>
            <th>Vencimento</th>
            <th>Carteira</th>
            <th>N. numero</th>
            <th>CNPJ</th>
            <th>Sacado</th>
            <th>Valor</th>
            <th>Depositaria</th>
            <th>Obs</th>
          </tr>
          <xsl:for-each select="/*/Dados/Item">
            <tr>
              <td>
                <center>
                  <xsl:value-of select="Venc"/>
                </center>
              </td>
              <td>
                <center>
                  <xsl:value-of select="Carteira"/>
                </center>
              </td>
              <td>
                <xsl:value-of select="NossoNum"/>-<xsl:value-of select="DacNossoNum"/>
              </td>
              <td>
                <center>
                  <xsl:value-of select="CGC"/>
                </center>
              </td>
              <td>
                <xsl:value-of select="Nome"/>
              </td>
              <td>
                <xsl:value-of select="Valor"/>
              </td>
              <td>
                <xsl:value-of select="Depos"/>
              </td>
              <td>
                <xsl:value-of select="Obs"/>
              </td>
            </tr>
          </xsl:for-each>
        </xsl:if>
    
      </xsl:template>
    
      <xsl:template name="NOK_REGISTROS">
        <tr>
          <td colspan="8">
            Nenhum registro foi localizado.
          </td>
        </tr>
      </xsl:template>
    
    </xsl:stylesheet>
    Last edited by Peterson Chaves; Jun 24 '11, 12:56 PM. Reason: Correct title.
Working...