tnorton25
New member
- Joined
- Aug 4, 2011
- Messages
- 1
- Programming Experience
- 3-5
I am attempting to send my XML file through an API. I have done this no problem by using the below code, however when I try and send the FILE over it will not work, does not give any errors just doesn't import any data.
Without trying to send FILE it works by creating data inside code:
But trying to send FILE it does NOT work, nothing happens, and no errors are given, here is FULL code. The file is replicated from the code above so I know the file is good:
Without trying to send FILE it works by creating data inside code:
VB.NET:
' create the Xml that the Msxml2.serverXmlHttp object will send to the Webservice
dim Xml_to_Send
Xml_to_Send = "<?xml version=""1.0"" encoding=""utf-8"" ?>"
Xml_to_Send = Xml_to_Send & "<xmldata>"
Xml_to_Send = Xml_to_Send & " <Products>"
Xml_to_Send = Xml_to_Send & " <ProductCode>THE-TEST</ProductCode>"
Xml_to_Send = Xml_to_Send & " <ProductPrice>100.00</ProductPrice>"
Xml_to_Send = Xml_to_Send & " </Products>"
Xml_to_Send = Xml_to_Send & "</xmldata>"
oXMLHttp.Send(Xml_to_Send)
VB.NET:
<%@ Page Title="MAIN" Language="vb" Explicit="true" AspCompat="true" %>
<%
dim doc As XDocument = XDocument.Load("sample.xml")
' create the Msxml2.serverXmlHttp object needed to post the Xml to the WebService
dim oXMLHttp
oXMLHttp = Server.CreateObject("Msxml2.serverXmlHttp")
oXMLHttp.open("POST", "http://www.mysite.com/net/WebService.aspx?Login=me@mysite.com&EncryptedPassword=XX&Import=Update", False)
oXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
oXMLHttp.setRequestHeader("Content-Action", "xmldata")
oXMLHttp.setTimeouts(100000, 100000, 600000, 9999999)
Server.ScriptTimeout = 10800
' Send the Xml
oXMLHttp.Send(doc)
' Display the Xml on the browser
Response.Write(doc)
' clean up
oXMLHttp = Nothing
doc = Nothing
%>