Hi,
I am using xdmp:login and setting the sessionId using
xdmp:set-seeion-field("session",xdmp:random())
and sending this value in response header using
xdmp:add-response-header("session",
xs:string(xdmp:get-session-field("session")) ).
Now, when the application hit using this sessionId, the session gets expired,
as xdmp:get-session-field("session") is returning no value.
But when I use postman to run the same code, its working fine.
Thanks
Pragya
In relateddocs.xqy:
declare variable $user := xdmp:get-request-header("user");
declare variable $password := xdmp:get-request-header("password");
declare variable $collection := xdmp:get-request-header("collection");
xdmp:add-response-header("Pragma", "No-Cache")
,
if($user eq "WebServiceUser" and $password eq "WebServiceUser") then
if( xdmp:login( $user, $password) ) then
try
{
let $result :=
let $dummy := xdmp:set-session-field("session",xdmp:random())
let $dummy := xdmp:log("IN rel docs")
let $dummy := xdmp:log(xs:string(xdmp:get-session-field("session")))
return
<documents collection ="{$collection }">
{ if ($collection) then
........
else ()
}
</documents>
return element result {$result}
}
catch($e)
{
$e
}
else
"Failed to Log-In"
else
"Failed to Log-In"
,
xdmp:add-response-header("session",
xs:string(xdmp:get-session-field("session")) )
In getpdf.xqy:
declare variable $docID := xdmp:get-request-field("docID");
xdmp:add-response-header("Pragma", "No-Cache")
,
let $sessionId := xs:string(xdmp:get-session-field("session"))
let $dummy := xdmp:log("In pdf.xqy")
let $dummy := xdmp:log($sessionId)
let $dummy := xdmp:log("amit session")
let $dummy := xdmp:log(xs:string(xdmp:get-request-field("session")))
return
if($sessionId eq xs:string(xdmp:get-request-field("session"))) then
if( xdmp:login( "WebServiceUser", "WebServiceUser") ) then
try
{
let $PDFDocID := if (fn:substring($docID,23,3) = "000" or
fn:substring($docID,23,1) = "V" or fn:contains($docID,"AMD-VDF2"))(: to check
virtual document:)
then
$docID
else
(: swap clone document URI for original document
URI, for which a PDF should exist! :)
fn:concat(fn:substring($docID,1,22), "000",
fn:substring($docID,26,999))
let $pdfID := fn:replace($PDFDocID,"/docs/","/SourcePDFs/")
let $pdfID := fn:replace($pdfID,".xml",".pdf")
return
(
xdmp:set-response-content-type("application/pdf")
,
fn:doc($pdfID)
)
}
catch($err)
{
(
xdmp:set-response-content-type("application/xml")
,
<result>SORRY: The PDF document you requested ("{$docID}") is not
available. Please contact Support.</result>
)
}
else
<result>No permissions to view this document</result>
else
"Failed to Log-In"
;
xdmp:logout()
"This e-mail and any attachments transmitted with it are for the sole use of
the intended recipient(s) and may contain confidential , proprietary or
privileged information. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this e-mail or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful."
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general