I am using the SOAP driver with IDM 4.0.1 to connect to an external
system. This system requires a token with each request. The method for
obtaining the token is to issue a login request to the interface in the
format as shown in the Client-otp-GetTokenSS stylesheet (in the output
transformation). Take note of the location of the namespace
declarations. These namespace declarations must be part of the request
document or the server rejects the request.

The response is shown in the Login Response document. *You will notice
that both documents contain a namespace declaration for
https://api.secure-company.com. This reference to the same namespace in
both documents has prevented me from being able to process both the
request and the response in the same stylesheet due to XPATH
limitations.

My solution has been to split the initial query into two separate
stylesheets. I initiate the original query in the
Client-Sub-ctp-GetTokenSS stylesheet (in the subscriber command
transformation). Then in the afore mentioned output transformation
stylesheet I capture the request and swap it our for the the correct
query document with the namespaces inserted. The problem I am having
with this approach is after I submit the document formatted as needed
the document is being rewritten by the engine to move one of my
necessary namespace declarations to the top level NDS element as is seen
in the attached trace file. This causes the namespace to be stripped out
prior to submission to the server which results in a failure to process
the SOAP envelope.

CLIENT-SUB-CTP-GETTOKENSS:


Code:
--------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="query cmd dncv" version="1.0" xmlns:cmd="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsCommandProcessor" xmlns:dncv="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.DNConverter" xmlns:query="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:api="https://api.secure-company.com">
<!-- parameters passed in from the DirXML engine -->
<xslaram name="srcQueryProcessor"/>
<xslaram name="destQueryProcessor"/>
<xslaram name="srcCommandProcessor"/>
<xslaram name="destCommandProcessor"/>
<xslaram name="dnConverter"/>
<xslaram name="fromNds"/>
<!-- identity transformation template -->
<!-- Capture add, modify and delete events and add the token value -->
<xsl:template match="add|modify|delete">
<xsl:copy>
<xsl:attribute name="token">
<xsl:value-of select="$resultToken"/>
</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
<xsl:message>token = <xsl:value-of select="$resultToken"/></xsl:message>
</xsl:template>
<!-- Variable constructed to retrieve the current token value from SMS -->
<xsl:variable name="query">
<nds dtdvrsion="4.0" ndsversion="8.x">
<input>
<operation-data soap-action="https://api.secure-company.com/ILoginService/Login"/>
<Envelope>
<soapenv:Header/>
<soapenv:Body>
<api:Login>
<api:request>
<api:LocationID>12345</api:LocationID>
<api:Password>joe123</api:Password>
<api:UserName>joe</api:UserName>
<api:client_id><xsl:value-of select="'~GCV-ClientID~'"/></api:client_id>
<api:client_secret><xsl:value-of select="'~GCV-ClientSecret~'"/></api:client_secret>
<api:grant_type/>
</api:request>
</api:Login>
</soapenv:Body>
</Envelope>
</input>
</nds>
</xsl:variable>
<!-- Variable constructed to initiate the call to retrieve the token value from SMS -->
<xsl:variable name="result" select="query:query($destQueryProcessor,$query)"/>
<!-- Variable constructed to extract the token value -->
<xsl:variable name="resultToken" select="$result//api:access_token/text()"/>
<!-- in the absence of any other templates this will cause -->
<!-- the stylesheet to copy the input through unchanged to the output -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--------------------



CLIENT-OTP-GETTOKENSS:


Code:
--------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="query cmd dncv" version="1.0"
xmlns:cmd="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsCommandProcessor"
xmlns:dncv="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.DNConverter"
xmlns:query="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- parameters passed in from the DirXML engine -->
<xslaram name="srcQueryProcessor"/>
<xslaram name="destQueryProcessor"/>
<xslaram name="srcCommandProcessor"/>
<xslaram name="destCommandProcessor"/>
<xslaram name="dnConverter"/>
<xslaram name="fromNds"/>
<!-- identity transformation template -->
<!-- Capture token query events and add the required namespace -->
<xsl:template match="Envelope">
<xsl:message>Output Transform - Match - Envelope</xsl:message>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="https://api.secure-company.com">
<soapenv:Header/>
<soapenv:Body>
<api:Login>
<api:request>
<api:LocationID>12345</api:LocationID>
<api:Password>joe123</api:Password>
<api:UserName>joe</api:UserName>
<api:client_id><xsl:value-of select="'~GCV-ClientID~'"/></api:client_id>
<api:client_secret><xsl:value-of select="'~GCV-ClientSecret~'"/></api:client_secret>
<api:grant_type/>
</api:request>
</api:Login>
</soapenv:Body>
</soapenv:Envelope>
</xsl:template>
<!-- in the absence of any other templates this will cause -->
<!-- the stylesheet to copy the input through unchanged to the output -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--------------------



LOGIN RESPONSE:


Code:
--------------------
<nds dtdversion="2.0">
<source>
<product build="20110402_112430" instance="SMS" version="3.5.6">Identity Manager Driver for SOAP</product>
<contact>Novell, Inc.</contact>
</source>
<output>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<LoginResponse xmlns="https://api.secure-company.com">
<LoginResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<access_token>2115e573-a23d-4aa5-8152-3c3422410132</access_token>
<error i:nil="true"/>
<error_description i:nil="true"/>
<expires_in>1209600</expires_in>
</LoginResult>
</LoginResponse>
</s:Body>
</s:Envelope>
</output>
</nds>
--------------------



TRACE SEGMENT:


Code:
--------------------
[04/10/13 11:39:15.238]:IDV-QA2:SMS ST:Applying XSLT policy: %+C%14CClient-Sub-ctp-GetTokenSS%-C.
[04/10/13 11:39:15.239]:IDV-QA2:SMS ST: Query from policy
[04/10/13 11:39:15.239]:IDV-QA2:SMS ST:
<nds dtdvrsion="4.0" ndsversion="8.x" xmlns:api="https://api.secure-company.com">
<input>
<operation-data soap-action="https://api.secure-company.com/ILoginService/Login"/>
<Envelope>
<soapenv:Header/>
<soapenv:Body>
<api:Login>
<api:request>
<api:LocationID>12345</api:LocationID>
<api:Password>joe123</api:Password>
<api:UserName>joe</api:UserName>
<api:client_id>removed from trace</api:client_id>
<api:client_secret>removed from trace</api:client_secret>
<api:grant_type/>
</api:request>
</api:Login>
</soapenv:Body>
</Envelope>
</input>
</nds>
[04/10/13 11:39:15.242]:IDV-QA2:SMS ST: Fixing up association references.
[04/10/13 11:39:15.242]:IDV-QA2:SMS ST: Applying schema mapping policies to output.
[04/10/13 11:39:15.242]:IDV-QA2:SMS ST: Applying policy: %+C%14CNOVLDSML-smp%-C.
[04/10/13 11:39:15.243]:IDV-QA2:SMS ST: Applying output transformation policies.
[04/10/13 11:39:15.243]:IDV-QA2:SMS ST: Applying XSLT policy: %+C%14CClient-otp-GetTokenSS%-C.
[04/10/13 11:39:15.244]:IDV-QA2:SMS ST: %13Cxsl:message -> Output Transform - Match - Envelope
[04/10/13 11:39:15.244]:IDV-QA2:SMS ST: Policy returned:
[04/10/13 11:39:15.245]:IDV-QA2:SMS ST:
<nds dtdvrsion="4.0" ndsversion="8.x" xmlns:api="https://api.secure-company.com">
<input>
<operation-data event-id="0" soap-action="https://api.secure-company.com/ILoginService/Login"/>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<api:Login>
<api:request>
<api:LocationID>12345</api:LocationID>
<api:Password>joe123</api:Password>
<api:UserName>joe</api:UserName>
<api:client_id>removed from trace</api:client_id>
<api:client_secret>removed from trace</api:client_secret>
<api:grant_type/>
</api:request>
</api:Login>
</soapenv:Body>
</soapenv:Envelope>
</input>
</nds>
--------------------


--
sfbrooks
------------------------------------------------------------------------
sfbrooks's Profile: https://forums.netiq.com/member.php?userid=4825
View this thread: https://forums.netiq.com/showthread.php?t=47555