dbsoracle
asked on
VB.net http request and response
Hello:
I am trying to convert the following Access 2003 code into vb.net 2.0
Thanks in advance for any help.
Any Ideas?
'''''''''''''''''''''''''' '''''''''' '''''''''' '''''''''' '''''''''' '''''''''' '''''''''' ''''
Function CallAPI(strXML As Variant)
Dim objXMLHTTP, dblqte As String
' Build the XML Open statement & Header Info
Set Misc = CurrentDb.OpenRecordset("M isc")
Misc.MoveFirst
url = Trim(Misc![url])
uname = Trim(Misc![username])
pwd = Trim(Misc![password])
Misc.Close
url = url & strXML
' Call the XMLHTTP Library functions
Set objXMLHTTP = CreateObject("Microsoft.XM LHTTP")
objXMLHTTP.Open "POST", url, False, uname, pwd
objXMLHTTP.SetRequestHeade r "Content-type", "application/x-www-form-ur lencoded"
objXMLHTTP.Send
'Debug.Print objXMLHTTP.ResponseText
CallAPI = objXMLHTTP.ResponseText
End Function
I am trying to convert the following Access 2003 code into vb.net 2.0
Thanks in advance for any help.
Any Ideas?
''''''''''''''''''''''''''
Function CallAPI(strXML As Variant)
Dim objXMLHTTP, dblqte As String
' Build the XML Open statement & Header Info
Set Misc = CurrentDb.OpenRecordset("M
Misc.MoveFirst
url = Trim(Misc![url])
uname = Trim(Misc![username])
pwd = Trim(Misc![password])
Misc.Close
url = url & strXML
' Call the XMLHTTP Library functions
Set objXMLHTTP = CreateObject("Microsoft.XM
objXMLHTTP.Open "POST", url, False, uname, pwd
objXMLHTTP.SetRequestHeade
objXMLHTTP.Send
'Debug.Print objXMLHTTP.ResponseText
CallAPI = objXMLHTTP.ResponseText
End Function
ASKER
Hi VBTurbo:
Thanks much for responding. The Access code actually calls a web service over the internet and that web service returns xml. In digging through .net, I think I need the HttpWebRequest and HttpWebResponse object. In order to call the web service, I also need to pass in user/password and I dont know how to attach that to the HttpWebRequest object, or possibly use .net's web services...???
Thanks much.
Thanks much for responding. The Access code actually calls a web service over the internet and that web service returns xml. In digging through .net, I think I need the HttpWebRequest and HttpWebResponse object. In order to call the web service, I also need to pass in user/password and I dont know how to attach that to the HttpWebRequest object, or possibly use .net's web services...???
Thanks much.
Hi
well here is a link regarding HttpWebRequest and sending credentials to the server ,though regarding webservice's my knowledge is zero
HttpWebRequest Class
WebRequest.PreAuthenticate Property
And the IAuthenticationModule.Auth enticate Method
http://msdn2.microsoft.com/en-us/library/system.net.iauthenticationmodule.authenticate(VS.71).aspx
vbturbo
well here is a link regarding HttpWebRequest and sending credentials to the server ,though regarding webservice's my knowledge is zero
HttpWebRequest Class
WebRequest.PreAuthenticate
And the IAuthenticationModule.Auth
http://msdn2.microsoft.com/en-us/library/system.net.iauthenticationmodule.authenticate(VS.71).aspx
vbturbo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It would be something like this , though you can change the local path to an URL instead
and read the data into a datatable
Private Sub Getdata()
Dim ds As New DataSet()
Dim reader As XmlTextReader = New System.Xml.XmlTextReader("
Dim dtbl As New DataTable
Dim dr As DataRow
Dim dv As New DataView(dtbl)
Dim objNodes As New System.Xml.XmlDocument
objNodes.Load(reader)
Dim oNodes As System.Xml.XmlNodeList
'set the parent node from where you want to start to read the child nodes.
oNodes = objNodes.SelectNodes("//sp
dtbl.Columns.Add(New DataColumn("col1", GetType(String)))
dtbl.Columns.Add(New DataColumn("col2", GetType(String)))
Dim node As System.Xml.XmlNode
For Each node In oNodes
dr = dtbl.NewRow()
dr(0) = node.Attributes.GetNamedIt
dr(1) = node.Attributes.GetNamedIt
'dr(1) = node.Item("file").InnerTex
dtbl.Rows.Add(dr)
Next
ds.Tables.Add(dtbl)
End Sub
hope this helps
vbturbo