http.PostXml not working

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
I am trying to send an xml string in memory to a web service. I am using a 3rd party component. They suggest I use:

VB.NET:
response = http.PostXml( url, xmlString, "utf-8")

I am using the Stock Quotes example.
I have previously set
VB.NET:
url = "http://testbpc.bai-uk.com/"
, and also

VB.NET:
xmlString = "<?xml version='1.0' encoding='utf-8' ?>" & vbCrLf
        xmlString = xmlString & "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" & vbCrLf
        xmlString = xmlString & "<soap:Body>" & vbCrLf
        xmlString = xmlString & "<GetQuote xmlns='http://www.webserviceX.NET/'>" & vbCrLf
        xmlString = xmlString & "<symbol>IBM</symbol>" & vbCrLf
        xmlString = xmlString & "</GetQuote>" & vbCrLf
        xmlString = xmlString & "</soap:Body>" & vbCrLf
        xmlString = xmlString & "</soap:Envelope>" & vbCrLf

followed by
VB.NET:
TextBox1.Text = "BodyStr:" & vbCrLf & http.PostXml(url, xmlString, "utf-8").Body.ToString

The response is:
BodyStr:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>The page cannot be displayed</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<STYLE type="text/css">
BODY { font: 8pt/12pt verdana }
H1 { font: 13pt/15pt verdana }
H2 { font: 8pt/12pt verdana }
A:link { color: red }
A:visited { color: maroon }
</STYLE>
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>

<h1>The page cannot be displayed</h1>
The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.
<hr>
<p>Please try the following:</p>
<ul>
<li>Contact the Web site administrator if you believe that this request should be allowed.</li>
<li>Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly. </li>
</ul>
<h2>HTTP Error 405 - The HTTP verb used to access this page is not allowed.<br>Internet Information Services (IIS)</h2>
<hr>
<p>Technical Information (for support personnel)</p>
<ul>
<li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>405</b>.</li>
<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr),
and search for topics titled <b>Setting Application Mappings</b>, <b>Securing Your Site with Web Site Permissions</b>, and <b>About Custom Error Messages</b>.</li>
</ul>

</TD></TR></TABLE></BODY></HTML>

I was expecting the response:

<StockQuotes>
<Stock>
<Symbol>IBM</Symbol>
<Last>91.95</Last>
<Date>3/18/2009</Date>
<Time>4:00pm</Time>
<Change>0.00</Change>
<Open>N/A</Open>
<High>N/A</High>
<Low>N/A</Low>
<Volume>0</Volume>
<MktCap>123.4B</MktCap>
<PreviousClose>91.95</PreviousClose>
<PercentageChange>0.00%</PercentageChange>
<AnnRange>69.50 - 130.93</AnnRange>
<Earns>8.925</Earns>
<P-E>10.30</P-E>
<Name>INTL BUSINESS MAC</Name>
</Stock>
</StockQuotes>

What have I missed? Thanks in advance.
 
Back
Top