NetTalk Central
The Rest Of NetTalk => The Rest - Ask For Help => Topic started by: tglomb on September 24, 2018, 01:08:24 PM
-
Hello,
I must Post (NetWebClient) XML data to an URL:Port. Somehow it doesnt works. Here my Code:
mycstring= '@XMLDATA=<?xml version="1.0" encoding="UTF-8"?>' & crlf & |
'<methodCall>' & crlf & |
'<methodName>DisplayStudy</methodName>' & crlf & |
'<params>' & crlf & |
....
'</params>' & crlf & |
'</methodCall>'
sender.SetAllHeadersDefault()
sender.HeaderOnly = 0
sender.Cookie = 'Cookie'
sender.Referer = 'Referer'
sender.ContentType = 'application/xml' ! -www-form-urlencoded'
sender.AcceptEncoding = ''
sender.Pragma_ = 'no-cache'
sender.Post( 'http://'& clip( theURLandPort) &'/', mycstring)
What's wrong ?
Any ideas and hints are welcome.
TIA, Thomas
-
>> What's wrong ?
many possible things, but it all depends on what the other end is expecting.
>> mycstring= '@XMLDATA=<?xml version=
this approach suggests the data is being past as a form-encoded value rather than as XML. If so it's like the actual XML string should be URLEncoded. (See StringTheory for a method on that.) Just the part after the = sign should be URL encoded.
sender.ContentType = 'www-form-urlencoded'
alternatively they may want actual XML - in which case it's likely @XMLDATA= should be drpped, the xml should be "as is" and the
sender.ContentType = 'application/xml'
lastly;
sender.Post( 'http://'& clip( theURLandPort) &'/', mycstring)
should be
sender.Post( 'http://'& clip( theURLandPort) , mycstring)
the trailing / is not desirable.
Cheers
Bruce
-
Thank you Bruce, it work's like a charm.
In my case I use now:
mycstring= '<?xml version="1.0" encoding="UTF-8"?>' & crlf & |
'<methodCall>' & crlf & |
'<methodName>DisplayStudy</methodName>' & crlf & |
'<params>' & crlf & |
....
'</params>' & crlf & |
'</methodCall>'
sender.SetAllHeadersDefault()
sender.HeaderOnly = 0
sender.Cookie = 'Cookie'
sender.Referer = 'Referer'
sender.ContentType = 'application/xml'
sender.AcceptEncoding = ''
sender.Pragma_ = 'no-cache'
sender.Post( 'http://'& clip( theURLandPort), mycstring)
Sender is a NetWebClient object, crlf='<13,10>'. Maybe I can drop the crlf.. but it works and not for 20 Bytes or so ;-) there's no chance to play..
Ciao, Thomas