Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem with Microsoft.XMLHTTP POST operations

Posted on 2006-11-03
9
Medium Priority
?
689 Views
Last Modified: 2008-03-03
Hi,

I have the following function that works great when operation = GET.  If operation = POST then the send function returns an exception "parameter is incorrect".  I've tried troubleshooting but nothing seems to want to work.  Help!

function  doXMLHTTPPost(url, xmlBody: string; operation: string): string;
var
  vHttp     : OleVariant;
begin
  vHttp := CreateOleObject('Microsoft.XMLHTTP'); { Requires IE5 }
  vHttp.open(operation, url, false, EmptyParam,EmptyParam);

  vHttp.send(xmlBody);

  result := vHttp.responseText;

end;
0
Comment
Question by:rdytmire
  • 5
  • 3
9 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 17871285
0
 
LVL 1

Author Comment

by:rdytmire
ID: 17872809
You'll notice that the link you provided refers to the msXML component not the msXMLHTTP component.  I am not mixing DOM components, I am not passing a DOM XML structure between processes and it's the SEND method, not the OPEN method that is throwing the exception.  So your link does not provide me with an answer.

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 17872835
How does your xmlBody looks like?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:rdytmire
ID: 17881061
I found the problem.  The declaration of xmlBody: string; was the issue.  the following line of code fixed the issue.

vHttp.send(WideString(xmlBody));


It seems I needed to convert the type of string before making the oleCall.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 17881181
Maybe you are building the string as String:

'<OBJECT>' + ...something... + '</OBJECT>'

If you are building it using XMLDocument you won't have "Invalid parameter". In your way you may experience problebs with special characters like < & >, etc.
0
 
LVL 1

Author Comment

by:rdytmire
ID: 17882927
XMLDocument is a very heavy-weight object and I try to avoid it whenever possible.  I currently use TNavitveXML for most of my XML needs.  The string in question IS being built in the manner you describe but I am aware of the escape characters and they do not introduce errors.  It really was just as simple as properly typecasting my response.
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 1500 total points
ID: 17887606
Darn, you answered it yourself... :-)
Well, the XMLHTTP and the MSXML libraries of Windows are unicode by default so for EVERY function you have to use WideString types and not regular string types. It's a bit of a pain, though. So use: function  doXMLHTTPPost(url, xmlBody: WIDESTRING; operation: WIDESTRING): string;

I agree that the TXMLDocument class is just too heavy to use comfortably but I do wonder why you're using late binding to access the XMLHTTP library. Why not import the type library in Delphi (without the component wrapper) and then use early binding? It will improve performance quite a bit too!
0
 
LVL 1

Author Comment

by:rdytmire
ID: 17888225
Thanks,

This was just a test-harness to make sure our theory will work correctly.  I'll clean up stuff in the final code.
0
 
LVL 1

Author Comment

by:rdytmire
ID: 18071017
As an aside for future readers:  We ended up going back to the idHTTP component and using it's POST method.  IE dependency just scared us too much.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question