From what you're posting here tje string looks fine - it doesn't have extended characters. But to be sure you should use STRCONV(cXML,9) to encode any possible extended characters.
Ideally it's best to build up the XML inside of the XMLDOM... You can use wwXML::AddElement() method which will properly encode values. You load an empty document, then call AddElement to add the nodes.
Also you should the content-encoding to UTF-8 and content type to text/xml when sending. So set cContentType explicitly to:
The error coming back from the server seems to indicate a failure of XML formatting, but it could also be a structural problem - maybe you're missing elements or values - I don't know. You'd have to check with the provider or try to dig up an example that you can check out and trace with Fiddler or in a browser. There may be other things that have to be matched.
Thank you Rick for your help! I'm still stumbling a bit maybe because I don't understand this business around UTF-8 enough.
1. Is there a public-domain web site where I could direct my XML packet and then it will show the results of parsing my packet?
2. Is there some way to turn on UTF-8 for oHTTP, such as oHTTP.AddPostKey(STRCONV(CXML,10))
3. I feel I would be better off actually using your wwSoap masterpieces, and then maybe those will solve the UTF-8 problem automatically. What would be code sample to generate a packet like what I'm trying to do in wwSoap?
To answer your question, the XML I'm sending is generated like this:
CR=CHR(13)+CHR(10)
CXML= '<?xml version="1.0" encoding="utf-8" ?>'+CR
CXML=CXML+ '<YourMembership>'+CR
CXML=CXML+ '<Version>1.95</Version>'+CR
CXML=CXML+ '<ApiKey>00000000-0000-0000-0000-0000000000</ApiKey>'+CR
CXML=CXML+ '<CallID>002</CallID>'+CR
CXML=CXML+ '<SaPasscode>********</SaPasscode>'+CR
CXML=CXML+ '<Call Method="Sa.Members.All.GetIDs">'+CR
CXML=CXML+ '<Timestamp>2008-01-01 00:00:00</Timestamp>'+CR
CXML=CXML+ '</Call>'+CR
CXML=CXML+ '</YourMembership>'
oHTTP = CREATEOBJECT("wwHttp")
oHTTP.HTTPConnect("api.yourmembership.com",,,.T.)
oHTTP.nHttpPostMode = 4
oHTTP.AddPostKey(CXML)
LCHTML=""
LNTEXT=0
lnResult=oHTTP.HTTPGetEx("/",@lcHTML,@lnText)
What I'm getting back from their system is this packet:
<?xmlversion="1.0" encoding="utf-8" ?><YourMembership_Response><ErrCode>902</ErrCode><ExtendedErrorInfo></ExtendedErrorInfo><ErrDesc>XML packet is malformed or otherwise unreadable.</ErrDesc><XmlRequest><unnamed></unnamed></XmlRequest></YourMembership_Response>
Thanks in advance again!
What does the actual XML look like? You have the doc set to utf-8 encoding but is the document actually UTF-8 encided?
You should validate the XML by loading it into an XML dom - that will tell you if there's a problem. IOW, if there are extended characters (or quotes or ampersands >< etc) in the content that will make the XML document fail to validate.
+++ Rick ---