By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

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

P: 1
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:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <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">
  3.   <soap:Body>
  4.     <KYRHResponse>
  5.       <KYRHResult>
  6.         <KYRH xmlns="">
  7.           <Informativo>
  8.             <Status>OK</Status>
  9.             <MsgErro></MsgErro>
  10.             <QtdRegistros>15</QtdRegistros>
  11.           </Informativo>
  12.           <Cabecalho>
  13.             <Item>
  14.               <NomeBanco>xxxxx</NomeBanco>
  15.               <Cabec>AGENCIA: xxxxx CONTA: xxxxx</Cabec>
  16.               <DataRef>21/06/11</DataRef>
  17.               <Cabec1>VCTO CRT  N.NUMERO  DEP.         VALOR     - SACADO (CGC E NOME) -  OBSERVACAO</Cabec1>
  18.             </Item>
  19.           </Cabecalho>
  20.           <Dados>
  21.             <Item>
  22.               <Venc>01/07</Venc>
  23.               <Carteira>112</Carteira>
  24.               <NossoNum>12121212</NossoNum>
  25.               <DacNossoNum>4</DacNossoNum>
  26.               <Depos>2861</Depos>
  27.               <Valor>1.316,27</Valor>
  28.               <BR></BR>
  29.               <CGC>11111111</CGC>
  30.               <Nome>xxxx xxxxxx</Nome>
  31.               <Obs></Obs>
  32.             </Item>
  33.           </Dados>
  34.         </KYRH>
  35.       </KYRHResult>
  36.     </KYRHResponse>
  37.   </soap:Body>
  38. </soap:Envelope>
  39.  
XSL file:

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3.  
  4.   <xsl:template match="/">
  5.  
  6.     <table border="1" cellpadding="2" padding="2">
  7.  
  8.       <xsl:if test="/*/*/*/*/*/*/Informativo/Status = 'OK'">
  9.  
  10.         <xsl:if test="/*//Informativo/QtdRegistros != 0">
  11.           <xsl:call-template name="OK_REGISTROS" />
  12.         </xsl:if>
  13.  
  14.         <xsl:if test="/*/Informativo/QtdRegistros = 0">
  15.           <xsl:call-template name="NOK_REGISTROS" />
  16.         </xsl:if>
  17.  
  18.       </xsl:if>
  19.  
  20.       <xsl:if test="/*/Informativo/Status = 'Erro'">
  21.         <xsl:call-template name="NOK"/>
  22.       </xsl:if>
  23.  
  24.     </table>
  25.  
  26.   </xsl:template>
  27.  
  28.   <xsl:template name="NOK">
  29.     <tr>
  30.       <td colspan="8">
  31.         Erro: <xsl:value-of select="/*/Informativo/MsgErro"/>
  32.       </td>
  33.     </tr>
  34.   </xsl:template>
  35.  
  36.   <xsl:template name="OK_REGISTROS">
  37.  
  38.     <xsl:if test="/*/Informativo/QtdRegistros > 0">
  39.       <tr>
  40.         <td colspan="8">
  41.           <hr />
  42.         </td>
  43.       </tr>
  44.       <tr>
  45.         <th>Vencimento</th>
  46.         <th>Carteira</th>
  47.         <th>N. numero</th>
  48.         <th>CNPJ</th>
  49.         <th>Sacado</th>
  50.         <th>Valor</th>
  51.         <th>Depositaria</th>
  52.         <th>Obs</th>
  53.       </tr>
  54.       <xsl:for-each select="/*/Dados/Item">
  55.         <tr>
  56.           <td>
  57.             <center>
  58.               <xsl:value-of select="Venc"/>
  59.             </center>
  60.           </td>
  61.           <td>
  62.             <center>
  63.               <xsl:value-of select="Carteira"/>
  64.             </center>
  65.           </td>
  66.           <td>
  67.             <xsl:value-of select="NossoNum"/>-<xsl:value-of select="DacNossoNum"/>
  68.           </td>
  69.           <td>
  70.             <center>
  71.               <xsl:value-of select="CGC"/>
  72.             </center>
  73.           </td>
  74.           <td>
  75.             <xsl:value-of select="Nome"/>
  76.           </td>
  77.           <td>
  78.             <xsl:value-of select="Valor"/>
  79.           </td>
  80.           <td>
  81.             <xsl:value-of select="Depos"/>
  82.           </td>
  83.           <td>
  84.             <xsl:value-of select="Obs"/>
  85.           </td>
  86.         </tr>
  87.       </xsl:for-each>
  88.     </xsl:if>
  89.  
  90.   </xsl:template>
  91.  
  92.   <xsl:template name="NOK_REGISTROS">
  93.     <tr>
  94.       <td colspan="8">
  95.         Nenhum registro foi localizado.
  96.       </td>
  97.     </tr>
  98.   </xsl:template>
  99.  
  100. </xsl:stylesheet>
  101.  
Jun 24 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.