Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MSXML2 and multipart posting
Message
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Title:
MSXML2 and multipart posting
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01051772
Message ID:
01051772
Views:
63
Hey all,

I am using MSXML2 to POST some data to a secure website, and the POSTed data utilizes "multipart/mixed" content.

I'm a bit baffled as to how I'm meant to include the extra contnt in the POST data.
Here is how the posed data is supposed to look:

POST /hapld/tos/kdwhapltos HTTP/1.1
Host: www.pld-certify.ups.com
Content-type: multipart/mixed; boundary=BOUNDARY
Content-length: 1040

--BOUNDARY
Content-type: application/x-www-form-urlencoded
Content-length: 140

AppVersion=1.0&AcceptUPSLicenseAgreement=Yes&ResponseType=application/x-ups-pld&VersionNumber=
V4R1&UserId=useridvalue&Password=passwordvalue

--BOUNDARY
Content-type: application/x-ups-binary
Content-length: 719

020082 2.0 2002101700000000000010500 000000001*AA0A1754 US
1234567002000001*BA1z1234560100002352 00001+0000000000000010 +000
0000000000000LBS01PRE10 3INUSD000001*CA18ATTENTION
DELIVERY 234 SOME LOCAL ST SO
ME CITY NJ 07652 US12015551212 *PA1z1234560100002352
02+0000010 +0000010
*SA000004

--BOUNDARY--

And here, essentially, is my code:
mURL="https://www.pld-certify.ups.com/hapld/tos/kdwhapltos"
LOCAL oXMLHTTP AS "MSXML2.ServerXMLHTTP"
LOCAL oError AS EXCEPTION
oXMLHTTP = CREATEOBJECT("MSXML2.ServerXMLHTTP")
oXMLHTTP.OPEN( "POST", mURL, .F. )
TRY
	oXMLHTTP.setRequestHeader("Content-type","multipart/mixed; boundry=BOUNDRY"+CHR(13)+CHR(10))
	mStr=GetPLD()
    oXMLHTTP.SEND(mStr)
    strReturn=oXMLHTTP.ResponseText
CATCH TO oError
    strReturn=oError.MESSAGE
ENDTRY
oXMLHTTP=.NULL.
MESSAGEBOX(strReturn)

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

PROCEDURE GetPLD() as String
mStr=""
mStr=mStr+"--BOUNDARY"+CHR(13)+CHR(10)
mStr=mStr+"Content-type: application/x-www-form-urlencoded"+CHR(13)+CHR(10)
mStr=mStr+"Content-length: 140"+CHR(13)+CHR(10)+CHR(13)+CHR(10)
mStr=mStr+"AppVersion=1.0&AcceptUPSLicenseAgreement=Yes&ResponseType=application/x-ups-pld&VersionNumber=V4R1&UserId=useridvalue&Password=passwordvalue"+CHR(13)+CHR(10)+CHR(13)+CHR(10)
mStr=mStr+"--BOUNDARY"+CHR(13)+CHR(10)
mStr=mStr+"Content-type: application/x-ups-binary"+CHR(13)+CHR(10)
mStr=mStr+"Content-length: 719"+CHR(13)+CHR(10)+CHR(13)+CHR(10)
mStr=mStr+"020082 2.0 2002101700000000000010500 000000001*AA0A1754 US1234567002000001*BA1z1234560100002352 00001+0000000000000010 +0000000000000000LBS01PRE10"
mStr=mStr+" 3INUSD000001*CA18ATTENTIONDELIVERY 234 SOME LOCAL ST SOME CITY NJ 07652 US12015551212 *PA1z123456010000235202+0000010 +0000010*SA000004"+CHR(13)+CHR(10)+CHR(13)+CHR(10)
mStr=mStr+"--BOUNDARY--"+CHR(13)+CHR(10)
RETURN mStr
ENDPROC
The response tells me that there's a "missing boundary" error.

Thanks!
John MR Fitzgerald
Order Inc.
Reply
Map
View

Click here to load this message in the networking platform