<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Reference &#187; asp</title>
	<atom:link href="http://sullivan.net/blog/tag/asp/feed/" rel="self" type="application/rss+xml" />
	<link>http://sullivan.net/blog</link>
	<description>A collection of code for my reference (and perhaps other people too)</description>
	<lastBuildDate>Wed, 25 Jan 2012 17:53:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>POST using ASP</title>
		<link>http://sullivan.net/blog/2010/05/post-using-asp/</link>
		<comments>http://sullivan.net/blog/2010/05/post-using-asp/#comments</comments>
		<pubDate>Mon, 31 May 2010 12:20:32 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[asp]]></category>

		<guid isPermaLink="false">http://sullivan.net/blog/?p=335</guid>
		<description><![CDATA[A more simple way to to a POST. This is cleaner than the last example I created. I used a nice function at http://www.secretgeek.net/XMLSendReceive.shtml. &#039; First load the XML to send off Set SendDoc = server.createobject(&#34;Microsoft.XMLDOM&#34;) SendDoc.ValidateOnParse= True SendDoc.LoadXML(sTrData) &#039; Then call the POST function and get a nice object back set SourceObj = xmlSend [...]]]></description>
			<content:encoded><![CDATA[<p>A more simple way to to a POST. This is cleaner than the last example I created.</p>
<p>I used a nice function at <a href="http://www.secretgeek.net/XMLSendReceive.shtml">http://www.secretgeek.net/XMLSendReceive.shtml</a>.</p>
<pre class="brush: vb">
&#039; First load the XML to send off
Set SendDoc = server.createobject(&quot;Microsoft.XMLDOM&quot;)
SendDoc.ValidateOnParse= True
SendDoc.LoadXML(sTrData) 

&#039; Then call the POST function and get a nice object back
set SourceObj = xmlSend (sURL, SendDoc)
</pre>
<p>Reading the XML:</p>
<pre class="brush: vb">
set oUid = SourceObj.documentElement.selectSingleNode(&quot;//UserId&quot;)
set oHtml = SourceObj.documentElement.selectSingleNode(&quot;//User/Name&quot;)
</pre>
<p>Here is the nifty little function</p>
<pre class="brush: vb">
    private function xmlsend(url, docSubmit)
        Set poster = Server.CreateObject(&quot;MSXML2.ServerXMLHTTP&quot;)
        poster.open &quot;POST&quot;, url, false
        poster.setRequestHeader &quot;CONTENT_TYPE&quot;, &quot;text/xml&quot;
        poster.send docSubmit
        Set NewDoc = server.createobject(&quot;Microsoft.XMLDOM&quot;)
        newDoc.ValidateOnParse= True
        newDoc.LoadXML(poster.responseTEXT)

        Set XMLSend = NewDoc
        Set poster = Nothing
    end function
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sullivan.net/blog/2010/05/post-using-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GET and POST using ASP</title>
		<link>http://sullivan.net/blog/2009/09/get-and-post-using-asp/</link>
		<comments>http://sullivan.net/blog/2009/09/get-and-post-using-asp/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 07:53:13 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[asp]]></category>

		<guid isPermaLink="false">http://sullivan.net/blog/?p=162</guid>
		<description><![CDATA[In these examples I am calling a WCF service. Many legacy projects out on the net are still using ASP. POST example with ASP xmlToSend = &#34;&#60;?xml version=&#34;&#34;1.0&#34;&#34; encoding=&#34;&#34;utf-8&#34;&#34; ?&#62;&#60;InputXMLObject xmlns=&#34;&#34;http://schemas.datacontract.org/2004/07/MyService&#34;&#34;&#62;&#60;FirstName&#62;Darren&#60;/FirstName&#62;&#60;LangCode&#62;UK&#60;/LangCode&#62;&#60;LastName&#62;Sullivan&#60;/LastName&#62;&#60;Address&#62;123 Rue de Nowhere&#60;/Address&#62;&#60;City&#62;Paris&#60;/City&#62;&#60;/InputXMLObject&#62;&#34; postUrl = &#34;http://myurl.com/MyService.svc/AddPerson&#34; Dim HttpReq Set HttpReq = Server.CreateObject(&#34;WinHttp.WinHttpRequest.5.1&#34;) HttpReq.Open &#34;POST&#34;, postUrl, False HttpReq.SetRequestHeader &#34;Content-Type&#34;, &#34;application/xml&#34; &#039;&#34;application/x-www-form-urlencoded&#34; HttpReq.Send xmlToSend PostXMLResponse = [...]]]></description>
			<content:encoded><![CDATA[<p>In these examples I am calling a WCF service. Many legacy projects out on the net are still using ASP.</p>
<p>POST example with ASP</p>
<pre class="brush: vb">
xmlToSend = &quot;&lt;?xml version=&quot;&quot;1.0&quot;&quot; encoding=&quot;&quot;utf-8&quot;&quot; ?&gt;&lt;InputXMLObject xmlns=&quot;&quot;http://schemas.datacontract.org/2004/07/MyService&quot;&quot;&gt;&lt;FirstName&gt;Darren&lt;/FirstName&gt;&lt;LangCode&gt;UK&lt;/LangCode&gt;&lt;LastName&gt;Sullivan&lt;/LastName&gt;&lt;Address&gt;123 Rue de Nowhere&lt;/Address&gt;&lt;City&gt;Paris&lt;/City&gt;&lt;/InputXMLObject&gt;&quot;

postUrl = &quot;http://myurl.com/MyService.svc/AddPerson&quot;
Dim HttpReq
Set HttpReq = Server.CreateObject(&quot;WinHttp.WinHttpRequest.5.1&quot;)
HttpReq.Open &quot;POST&quot;, postUrl, False
HttpReq.SetRequestHeader &quot;Content-Type&quot;, &quot;application/xml&quot;	&#039;&quot;application/x-www-form-urlencoded&quot;
HttpReq.Send xmlToSend
PostXMLResponse = HttpReq.ResponseText
</pre>
<p>GET example with ASP</p>
<pre class="brush: vb">
getUrl = &quot;http://MyUrl/MyService.svc/AddPerson?FirstName=Darren&amp;LastName=Sullivan&amp;Address=123 Rue de Nowhere&amp;City=Paris&amp;langCode=UK&quot;

Set xmlhttp = CreateObject(&quot;MSXML2.ServerXMLHTTP&quot;)
xmlhttp.open &quot;GET&quot;, getUrl, False
xmlhttp.setRequestHeader &quot;Content-type&quot;, &quot;text/xml&quot;
xmlhttp.send()
GetXMLResponse = xmlhttp.responseText
</pre>
<p>Process the XML result</p>
<pre class="brush: vb">
Set SourceObj = Server.CreateObject(&quot;MSXML2.DOMDocument.6.0&quot;)
SourceObj.async = false
SourceObj.setProperty &quot;SelectionLanguage&quot;, &quot;XPath&quot;
&#039;SourceObj.loadXML( GetXMLResponse ) &#039; For the GET call
SourceObj.loadXML( PostXMLResponse ) &#039; For the POST call

Dim NewRecordID, Success, ErrorString

set NewRecordID	= SourceObj.documentElement.selectSingleNode(&quot;//RecordID&quot;)
set Success = SourceObj.documentElement.selectSingleNode(&quot;//Success&quot;)
set ErrorString = SourceObj.documentElement.selectSingleNode(&quot;//ErrorString&quot;)

if not ErrorStringis nothing then
	ErrorText = ErrorString.text
else
	ErrorText = &quot;&quot;
end if
...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sullivan.net/blog/2009/09/get-and-post-using-asp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

