Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
HTTP Authentication and XML
Message
From
05/05/2008 09:36:15
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01314247
Message ID:
01315094
Views:
33
>That's something they should tell you. Ask their programmer to send you some code in asp or whatever he uses, or just a simple html file that does the call. It's possible for instance to pass the username and password in one call, like in lxmlObj.Send( "UserName="+lcUserName+"&Password="+lcPassword ).

Ok, they explained a bit more, that it needed to have Base64 encryption and the format to send, but it still pops-up the a User Name and Password form. Is there something in the following code that doesn't look right?
DO declare
 
LOCAL cBuffer, cEncoded, cDecoded
local lcURL, lxmlObj, lcResponse
 
lcWSDL = "https://teligibility.transactions.mckhboc.com:5002/Realtime/services/realtime?WSDL"

lcUserName = "testuser1"
lcPassword = "Webpass1"
cBuffer = lcUserName + ':' + lcPassword

lcURL = lcWSDL
lxmlObj = CreateObject("Microsoft.XMLHTTP")

lxmlObj.Open( "POST", lcURL, .F. )

** depending on the xml data passed later on, you may need:
lxmlObj.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
*****

cEncoded = ToBase64(cBuffer)
cDecoded = FromBase64(cEncoded)

cAuthenticate = "Basic " + cEncoded

lxmlObj.Open("GET", lcURL, .F., cAuthenticate)
	
lxmlObj.Send() && This is where the form pops-up

lcResponse = lxmlObj.ResponseText

RETURN


FUNCTION ToBase64(cSrc)
    LOCAL nFlags, nBufsize, cDst
    nFlags=1  && base64
 
    nBufsize=0
    = CryptBinaryToString(@cSrc, LEN(cSrc),;
        m.nFlags, NULL, @nBufsize)
 
    cDst = REPLICATE(CHR(0), m.nBufsize)
    IF CryptBinaryToString(@cSrc, LEN(cSrc), m.nFlags,;
        @cDst, @nBufsize) = 0
        RETURN ""
    ENDIF
RETURN cDst
 
FUNCTION FromBase64(cSrc)
#DEFINE CRYPT_STRING_NOCRLF 0x40000000
#DEFINE CRYPT_STRING_NOCR 0x80000000
    LOCAL nFlags, nBufsize, cDst
    nFlags=1  && base64
 
    nBufsize=0
    = CryptStringToBinary(@cSrc, LEN(m.cSrc),;
        nFlags, NULL, @nBufsize, 0,0)
 
    cDst = REPLICATE(CHR(0), m.nBufsize)
    IF CryptStringToBinary(@cSrc, LEN(m.cSrc),;
        nFlags, @cDst, @nBufsize, 0,0) = 0
        RETURN ""
    ENDIF
RETURN m.cDst
 
PROCEDURE declare
    DECLARE INTEGER CryptBinaryToString IN Crypt32;
        STRING @pbBinary, LONG cbBinary, LONG dwFlags,;
        STRING @pszString, LONG @pcchString
 
    DECLARE INTEGER CryptStringToBinary IN crypt32;
        STRING @pszString, LONG cchString, LONG dwFlags,;
        STRING @pbBinary, LONG @pcbBinary,;
        LONG pdwSkip, LONG pdwFlags
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform