I can't be sure, but I think you might be encoding things too much, if that makes sense? Granted, I operate over an open connection, but this is how I do it (FoxPro code, hopefully it makes sense). This is what generating a URL to view a document might look like:
LPARAMETERS pcFilecabinetGUID, puDocumentID, plDontRunURL, plUseWindowsAuth
IF (VARTYPE(pcFilecabinetGUID) <> "C") OR EMPTY(ALLTRIM(pcFilecabinetGUID))
* We cannot proceed without a file cabinet GUID.
* Document ID can be passed in as a numeric value or a string.
IF (VARTYPE(puDocumentID) == "C")
puDocumentID = VAL(puDocumentID)
IF (VARTYPE(puDocumentID) <> "N")
* We cannot proceed without a numeric document ID.
SET PROCEDURE TO GlobalProc ADDITIVE
* Establish a base URL with a viewer as the integration type.
lcURL = DWGetBaseIntegrationURL(DW_INTEGRATION_TYPE_VIEWER, plUseWindowsAuth)
* Add on file cabinet GUID.
lcURL = lcURL + "&fc=" + pcFilecabinetGUID
* Add on the document ID.
lcURL = lcURL + "&did=" + ALLTRIM(STR(INT(puDocumentID)))
IF (NOT plDontRunURL)
* Execute the URL.
* The URL used can be returned.
Here is what DWGetBaseIntegrationURL()
LPARAMETERS pcIntegrationType, plUseWindowsAuth, plDontDisplayOneDoc
IF (VARTYPE(pcIntegrationType) == "C")
pcIntegrationType = UPPER(ALLTRIM(pcIntegrationType))
* An empty integration type will make the URL be login-only.
pcIntegrationType = ""
LOCAL lcBaseURL, lcParams
* Start with our integration entry point.
* Use NTML entry point.
lcBaseURL = DW_INTEGRATION_ENTRY_POINT_NTLM
lcBaseURL = DW_INTEGRATION_ENTRY_POINT
lcParams = ""
* Now generate parameters, starting with login credentials (if we are not using a Windows login).
IF (NOT plUseWindowsAuth)
* We are NOT going use Windows authentication, so use login credentials generated here.
lcParams = lcParams + "&lc=" + DWGetURLIntegrationCreds()
* We can set any other defaults here, too.
IF (pcIntegrationType == DW_INTEGRATION_TYPE_RESULTLIST_VIEWER) OR (pcIntegrationType == DW_INTEGRATION_TYPE_HISTORY)
IF (NOT plDontDisplayOneDoc)
lcParams = lcParams + "&displayOneDoc=true"
* Finally, add on the integration type parameter, if we have one.
IF (NOT EMPTY(pcIntegrationType))
lcParams = lcParams + "&p=" + pcIntegrationType
IF (NOT EMPTY(lcParams))
IF (LEFT(lcParams, 1) = "&")
* Do not need the ampersand on the first parameter.
lcParams = SUBSTR(lcParams, 2)
lcBaseURL = lcBaseURL + "?" + lcParams
And finally, here is what DWGetURLIntegrationCreds()
SET PROCEDURE TO GlobalProc ADDITIVE
LOCAL lcPlainCreds, lcEncodedCreds
* Start with a plain-text credential string. We use a literal "\n" to denote a new-line character
* between username and password, as that is how DocuWare expect the credentials to be encoded.
lcPlainCreds = "User=" + DW_USERNAME_URL_INTEGRATION + "\nPwd=" + DW_PASSWORD_URL_INTEGRATION
* URL encode the plain text into a login credential string.
lcEncodedCreds = UrlTokenEncode(lcPlainCreds)
function does this (looks the same as yours):
* This function takes in a string and encodes it the same way System.Web.HttpServerUtility.UrlTokenEncode()
* would to in .NET:
* 1. Use STRCONV to convert the input to Base64.
* 2. Replace "+" with "-" and "/" with "_". Example: Foo+bar/=== becomes Foo-bar_===.
* 3. Replace any number of "=" at the end of the string with an integer denoting how many they were. Example: Foo-bar_=== becomes Foo-bar_3.
LOCAL lcEncoded, lnNumEqualSigns
* 1. Convert string to Base64.
lcEncoded = STRCONV(lcURL, 13)
* 2. Replace certain characters with others.
lcEncoded = CHRTRAN(lcEncoded, "+/", "-_")
* 3. See how many "=" are at the end of the encoded string and convert to digit.
lnNumEqualSigns = LEN(lcEncoded) - LEN(RTRIM(lcEncoded, 1, "="))
lcEncoded = LEFT(lcEncoded, LEN(lcEncoded) - lnNumEqualSigns)
lcEncoded = lcEncoded + ALLTRIM(STR(lnNumEqualSigns))
After all this, the URL is sent as-is -- no further encryption. User credentials and the query parameter are Url encoded, but that is it.
Maybe that won't work if you are using a secure connection, but on my system what I generate matches the URL Integrator, and the URLs work to do things like view documents. Your user credentials look correct, so it must be something with encrypting/encoding.