Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Can Send The XML request through HTTP post as parameter

Status
Not open for further replies.

shahriar2010

IS-IT--Management
Apr 28, 2010
6
0
0
US
I'm not that great with ASP , But I am trying to send The XML request through HTTP post as a value of a parameter
called Request.
Here the sample :

xmlString = “Request=<?xml version="1.0" encoding="UTF-8"
standalone="yes"?><VerificationRequest>< ID>XYZ</ID><Key>jhutry</Key><UID>6276109478228235</UID
></VerificationRequest>”

I Used Msxml2.ServerXMLHTTP.6.0 Method but I got the error “Invalid at the top level of the document” . When I omit the Parameter Request from xmlString, it’s work But I need to send this Parameter through HTTP post for get the right answer.

Can someone Help me how can I make it done.
This is the code that I used ,

Set SendDoc = server.createobject("Microsoft.XMLDOM")
SendDoc.ValidateOnParse= True
SendDoc.LoadXML(xmlString)
url = test site.com/checkID
Set poster = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")

poster.open "POST", url, false
poster.setRequestHeader "CONTENT_TYPE", "text/xml"
poster.send SendDoc

Set docReceived = server.createobject("Microsoft.XMLDOM")
docReceived.ValidateOnParse= True
docReceived.LoadXML(poster.responseTEXT)

Thanks,
Shahriar
 
well, SendDoc.LoadXML() expects a true valid XML string, and

Code:
"Request=<?xml version="1.0" encoding="UTF-8 standalone="yes"?>
<VerificationRequest>
< ID>XYZ</ID>
<Key>jhutry</Key>
<UID>6276109478228235</UID>
</VerificationRequest>"

is not.
This XML is a "VerificationRequest", so normally i would expect that the receiver "knows" we do a request.

Your source looks good, and copied from here. Compare this:
And add the debugging lines to your code, so you can inspect the answer you receive
 
When send the XML string with out the Request Parameter I got the error from the receiver called The “Request” parameter has an empty value, It means receiver needs this parameter as a part of a xml string.

Can I use another method to send it?
 
Are you sure you have all the XML fields?
eg:
Code:
<?xml version="1.0" encoding="UTF-8 standalone="yes"?>
<VerificationRequest>
 <request>Some value</request>
 < ID>XYZ</ID>
 <Key>jhutry</Key>
 <UID>6276109478228235</UID>
</VerificationRequest>
</code>

Is [URL unfurl="true"]https://www.my[/URL] test site.com/checkID
your own site? then the receiving source would be interesting!
 
Yes I have , I allready test it but as I said the receiver first looking for this parameter.My friend did it with ASP.net and its work.
I think, I have to use another method.What you think?
 
why not use ASP.NET (for this part) yourself then?
test site.com/checkID is not owned by you?
If yes: post the source of the receiving script.
If not: did you request them information about this "web service"?
 
I can't use ASP.NET and also this is not my own site but I have Implementation guide with the complete URL Post Description , URL Post Response and General Error Codes.
But I need to know why we cannot send this contain as I post it with ASP ?

"Request=<?xml version="1.0" encoding="UTF-8 standalone="yes"?>
<VerificationRequest>
< ID>XYZ</ID>
<Key>jhutry</Key>
<UID>6276109478228235</UID>
</VerificationRequest>
 
Request=<?xml version="1.0" encoding="UTF-8 standalone="yes"?>
<VerificationRequest>
< ID>XYZ</ID>
<Key>jhutry</Key>
<UID>6276109478228235</UID>
</VerificationRequest>"

is not XML (IMHO)

"<?xml version="1.0" encoding="UTF-8 standalone="yes"?>
<VerificationRequest>
< ID>XYZ</ID>
<Key>jhutry</Key>
<UID>6276109478228235</UID>
</VerificationRequest>"

is.

is it possible to post the ASP code of your friend so we can compare?
 
Yes ,

method check_ac.btn1_Click(sender: Object; e: EventArgs);
begin
var request: WebRequest := WebRequest.&Create(' test site.com/checkID');
request.&Method := 'POST';
var s: String := 'request=<?xml version="1.0" encoding="UTF-8 standalone="yes"?>
<VerificationRequest>
< ID>XYZ</ID>
<Key>jhutry</Key>
<UID>6276109478228235</UID>
</VerificationRequest>"
var bytes: array of Byte := Encoding.UTF8.GetBytes(s);
request.ContentType := 'application/x- request.ContentLength := bytes.Length;
var requestStream: Stream := request.GetRequestStream;
requestStream.&Write(bytes, 0, bytes.Length);
requestStream.Close;
var response: WebResponse := request.GetResponse;
Console.WriteLine((response as HttpWebResponse).StatusDescription);
inherited Response.&Write((response as HttpWebResponse).StatusDescription);
requestStream := response.GetResponseStream;
var reader: StreamReader := new StreamReader(requestStream);
var str2: String := reader.ReadToEnd;
Console.WriteLine(str2);
inherited Response.&Write(str2.ToString);
reader.Close;
requestStream.Close;
response.Close
end;
 
Ok Thank you , I found it.

In this case I just sent the xmlstring instead of SendDoc.xml

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top