Adding information to SOAP Header

<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:dp="http://www.datapower.com/extensions" 
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 extension-element-prefixes="dp">
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:strip-space elements="*"/>
 
<xsl:template match="@*|node()">
     <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
 </xsl:template>
 
 <xsl:template match="/soapenv:Envelope">
     <xsl:copy>
       <soapenv:Header>
          <KullaniciAdi  xmlns="apinizer.com">Ankara123</KullaniciAdi>
       </soapenv:Header>
         <xsl:apply-templates/>
     </xsl:copy>
 </xsl:template>
 
 <xsl:template match="soapenv:Header"/>
 
 </xsl:stylesheet>
XML

Adding literals to incoming XML message

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:sendSingleSMS>
         <tem:numbers>05551112233</tem:numbers>
         <tem:message>Test</tem:message>
         <tem:sd>0</tem:sd>
         <tem:ed>0</tem:ed>
      </tem:sendSingleSMS>
   </soapenv:Body>
</soapenv:Envelope>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet extension-element-prefixes="dp" version="1.0"
  xmlns:dp="http://www.datapower.com/extensions"
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:tem="http://tempuri.org/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/>
  <xsl:strip-space elements="*"/>
  <!-- identity transform -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="/soapenv:Envelope">
    <xsl:copy>
      <soapenv:Body>
        <tem:sendSingleSMS>
          <tem:username>aaa</tem:username>
          <tem:password>123</tem:password>
          <tem:origin>localhost</tem:origin>
          <xsl:copy-of select="//*[local-name() = 'numbers']"/>
          <xsl:copy-of select="//*[local-name() = 'message']"/>
          <xsl:copy-of select="//*[local-name() = 'sd']"/>
          <xsl:copy-of select="//*[local-name() = 'ed']"/>
        </tem:sendSingleSMS>
      </soapenv:Body>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="soapenv:Body"/>
</xsl:stylesheet>
XML

Adding Security Fields to SOAP Header

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:dp="http://www.datapower.com/extensions"
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 extension-element-prefixes="dp">
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
 <xsl:strip-space elements="*"/>
  
 <!-- identity transform -->
 <xsl:template match="@*|node()">
     <xsl:copy>
         <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
 </xsl:template>
  
 <xsl:template match="/soapenv:Envelope">
     <xsl:copy>
       <soapenv:Header>
         <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
          <wsse:UsernameToken wsu:Id="UsernameToken-234CF6365A5653A34C15439163051191">
             <wsse:Username>username</wsse:Username>
             <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
             <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">nonce</wsse:Nonce>
             <wsu:Created>2018-12-04T09:38:25.117Z</wsu:Created>
          </wsse:UsernameToken>
       </wsse:Security>
       </soapenv:Header>
         <xsl:apply-templates/>
     </xsl:copy>
 </xsl:template>
  
 <xsl:template match="soapenv:Header"/>
  
 </xsl:stylesheet>
XML


Adding deafult value to body - using a namespace

(#Alttaki parantez içeriği alternatiftir)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pat="http://schemas.xmlsoap.org/soap/envelope" 
xmlns="http://schemas.xmlsoap.org/soap/envelope"
version="1.0" >
   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
   <xsl:strip-space elements="*" />
   <xsl:template match="@*|node()">
      <xsl:copy>
         <xsl:apply-templates select="@*|node()" />
      </xsl:copy>
   </xsl:template>
   <xsl:template match="/soapenv:Envelope">
      <xsl:copy>
        <soapenv:Header/>
            <soapenv:Body>
                <pat:getTradeMarksByApplicationNo>
                    <xsl:copy-of select="//*[local-name() = 'applicationNo']"/>
					<pat:arg0><xsl:copy-of  select="//*[local-name() = 'arg0']/text()" /></pat:arg0> 
                    <pat:userName>kullaniciAdi</pat:userName>
                    <pat:passWord>sifreDegeri</pat:passWord>
                    <pat:requester>kurumAdi</pat:requester>
                </pat:getTradeMarksByApplicationNo>
            </soapenv:Body>
      </xsl:copy>
   </xsl:template>
 
<xsl:template match="soapenv:Header" />

(#veya

<xsl:template match="/S:Envelope/S:Header">
	<xsl:copy-of  select="/S:Envelope/S:Header" />
</xsl:template>
)
</xsl:stylesheet>
 
XML


Extracting composite file, header and redundant body content

(#namespace'ler default eklendi, abc namespace'i SorgulaResponse'ta idi ve ismi yoktu. İsim verilip altındaki tüm objeler bununla başlatıldı)

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="http://kps.nvi.gov.tr/2011/01/01"

xmlns:s="http://www.w3.org/2003/05/soap-envelope" 
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:a="http://www.w3.org/2005/08/addressing" 
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:b="http://schemas.datacontract.org/2004/07/Common.Types.Containers.Services">
    <xsl:template match="/">
     <Envelope><Header/><Body>
        <xsl:apply-templates select="s:Envelope/s:Body/abc:SorgulaResponse/abc:SorgulaResult/abc:SorguSonucu/abc:BilesikKutukBilgileri/abc:TCVatandasiKisiKutukleri/*"/>
         </Body></Envelope>
    </xsl:template>
    
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
</xsl:stylesheet>
XML



Adding static value inside the first method in body

(# Dikkat! Eğer 2. satırdaki soapenv, xml'dekinden (soap, sp, vs..) farklı ise eklediği yeni alanları namespace'li ekliyor)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                version="1.0">
  <xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/>
    <xsl:strip-space elements="*"/>
    
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

<xsl:template match="soapenv:Body/child::node()" >
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
		<kullaniciAd>1</kullaniciAd>
        <sifre>2</sifre>
	</xsl:copy>
  </xsl:template>

</xsl:stylesheet>

---alternative

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"  
xmlns:ns0="http://ws.sgk100wsV2.sgk.gov.tr/"
version="1.0" >
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
    <xsl:strip-space elements="*" />
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
    </xsl:template>
    <xsl:template match="/S:Envelope/S:Body/*[1]">
        <xsl:copy>
            <arg0>
                <xsl:copy-of  select="//*[local-name() = 'arg0']/text()" />
            </arg0>                                                
            <arg1>kullaniciAdi</arg1>
            <arg2>sifreDegeri</arg2>
            <arg3>arg3 degeri</arg3>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="/S:Envelope/S:Header">
        <xsl:copy-of select="/S:Envelope/S:Header" />
    </xsl:template>
</xsl:stylesheet>
XML