2011-05-08 58 views
1

我試圖攔截Web服務調用,以使用xsl更改webservice(用戶名令牌和密碼)的用戶憑據。使用xsl爲Siebel服務更改soap的usernametoken和soap消息的密碼

SO調用就像客戶端 - >攔截器(更改用戶憑據)+任何其他更改 - >調用原始oracle ERP/Siebel Web服務。

這是要通過xsl完成...我嘗試過各種選項,但它沒有工作... 很需要幫助...搜索了很多網站,但無法找到正確的答案。

Web服務請求的樣品如下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://siebel.com/CustomUI" > 
    <soapenv:Header> 
     <UsernameToken xmlns="http://siebel.com/webservices">Bill</UsernameToken> 
    <PasswordText xmlns="http://siebel.com/webservices">Gates</PasswordText>    
     <SessionType xmlns="http://siebel.com/webservices">None</SessionType> 
    </soapenv:Header> 
<soapenv:Body> 
     <cus:SiebelService> 
     <a>testvalue1</a> 
     <b>testvalue2</b> 
     </cus:SiebelService> 
</soapenv:Body> 
</soapenv:Envelope> 

這應該使用XSL,得到如下的輸出被轉換:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://siebel.com/CustomUI" > 
<soapenv:Header> 
      <UsernameToken xmlns="http://siebel.com/webservices">Steve</UsernameToken> 
      <PasswordText xmlns="http://siebel.com/webservices">Balmer</PasswordText>   
      <SessionType xmlns="http://siebel.com/webservices">None</SessionType> 
</soapenv:Header> 
<soapenv:Body> 
     <cus:SiebelService> 
     <a>testvalue1</a> 
     <b>testvalue2</b> 
     </cus:SiebelService> 
</soapenv:Body> 
</soapenv:Envelope> 
+0

好問題,+1。查看我的答案,獲得完整,簡短和簡單的解決方案。 – 2011-05-08 21:15:39

回答

0

該轉化

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:x="http://siebel.com/webservices"> 
<xsl:output omit-xml-declaration="yes" indent="yes"/> 
<xsl:strip-space elements="*"/> 

<xsl:template match="node()|@*"> 
    <xsl:copy> 
    <xsl:apply-templates select="node()|@*"/> 
    </xsl:copy> 
</xsl:template> 

<xsl:template match="x:UsernameToken/text()">Steve</xsl:template> 
<xsl:template match="x:PasswordText/text()">Ballmer</xsl:template> 
</xsl:stylesheet> 
當應用程序

滅蠅燈所提供的XML文檔

<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:cus="http://siebel.com/CustomUI" > 
    <soapenv:Header> 
     <UsernameToken 
     xmlns="http://siebel.com/webservices">Bill</UsernameToken> 
     <PasswordText 
     xmlns="http://siebel.com/webservices">Gates</PasswordText> 
     <SessionType 
     xmlns="http://siebel.com/webservices">None</SessionType> 
    </soapenv:Header> 
    <soapenv:Body> 
     <cus:SiebelService> 
      <a>testvalue1</a> 
      <b>testvalue2</b> 
     </cus:SiebelService> 
    </soapenv:Body> 
</soapenv:Envelope> 

產生通緝的結果

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:cus="http://siebel.com/CustomUI"> 
    <soapenv:Header> 
     <UsernameToken xmlns="http://siebel.com/webservices">Steve</UsernameToken> 
     <PasswordText xmlns="http://siebel.com/webservices">Ballmer</PasswordText> 
     <SessionType xmlns="http://siebel.com/webservices">None</SessionType> 
    </soapenv:Header> 
    <soapenv:Body> 
     <cus:SiebelService> 
     <a>testvalue1</a> 
     <b>testvalue2</b> 
     </cus:SiebelService> 
    </soapenv:Body> 
</soapenv:Envelope> 

說明:選擇名稱wose元素在默認命名空間是一個常見問題。在xpath和xslt標籤中搜索「默認命名空間」。