MSXML2.ServerXMLHTTP

D

dado49

I'm trying to post xml to a server using ServerXMLHTTPRequest from an
aspx.

Dim objXML As New System.Xml.XmlDataDocument
objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXML.open("POST",
"https://secure1.revilution.dk/api/index.php", False)

I know msxml from aspx is not suportet. Anyone have any ideas how to do
this?
 
E

EJSawyer

I'm puzzled as to why you'd *want* to do this, considering the flexibility of
the SOAP client in .Net. You may want to reevaluate.

However, if you truly need to do this, you need to use COM Interop. Add a
reference to your project for the MSXML type library, and then use the
objects that reference provides. You can't just use a .Net class (e.g.
System.Xml.XmlDataDocument) to hold a reference to a COM object.

Also, if you really need to use the COM objects, you may want to consider
the IXMLHTTPRequest class instead of the IServerXMLHTTPRequest, unless you're
doing a high traffic page, or you need to circumvent the WinInet stack (for
example, to override the proxy settings for outgoing traffic).
IXMLHTTPRequest is a bit simpler to use.

Erik J Sawyer
CFT Programmer
Appro Systems
 
D

dado49

I try to loook another solution. I found System.Net.HttpWebRequest.
What do you thing about that? I didn't test it.
 
E

EJSawyer

You can use System.Net.HttpWebRequest, but you'd have to do all the
formatting for the request, and parsing for the return result, yourself.

But the .Net framework provides all the infrastructure you need to call web
services, and it all works just fine from within an ASPX page or ASMX
service. All it takes is to add a web reference to your project within
Visual Studio. Studio will build a fully-functional SOAP client proxy
object, based on System.Web.Services.Protocols.SoapHttpClientProtocol.

Erik J Sawyer
CFT Programmer
Appro Systems
 
D

dado49

I tryed to look at 'IXMLHTTPReques' but I have a problem :0/
my code:

Dim HttpReq As New MSXML.IXMLHTTPReques
HttpReq.open("GET", "https://secure1.revilution.dk/api/index.php",False)
HttpReq.send()
MsgBox(HttpReq.responseText

the problem is 'MSXML.IXMLHTTPReques'is dot defined.
I import:
Imports System.Xml
Imports System.Net
 
E

EJSawyer

IXMLHTTPRequest, and the rest of the MSXML classes, are COM objects. Not
..Net. Therefore, you have to use COM interop.

If you're using Visual Studio, it's pretty easy. In the Solution Explorer
window (normally the top-right pane, click the "Solution" tab), expand your
solution and right-click the "References" branch. Click "Add Reference". In
the dialog that comes up, choose the COM tab, and scroll down to Microsoft
XML (choose your preferred version; v4.0 is the latest general release, v5.0
ships only with Office 2003, and v6.0 is in beta to ship with Studio 2005).
Click Select to add the COM library to the bottom window, and click OK.
Studio will then auto-generate all the namespace and interop marshalling
stuff to give you full access to the COM classes. You can then use these
pretty much as any .Net class.

You may also want to look at:
http://msdn.microsoft.com/library/en-us/vbcn7/html/vaconCOMInteroperability.asp

I still find it strange that you insist on going this route, though. You
should seriously consider using the SOAP client support built into the .Net
framework.

- EJS
 
D

dado49

Thnak you wery much for your answers.
I'm not expert in asp.net. I just started with it. I'm a student and
working on my projekt exam. We have be workong on this problem in 2 days
and wi still have a proble.
I have a question about SOAP - when I try to add webservice to use soap
I got a error message from the url.

ERROR:
The document at the url https://secure1.revilution.dk/api/index.php was
not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'WSDL Document' is 'There is an error in XML document (2,
2).'.

This is our latest try:

Dim requestText As Object
Dim serverResponseText As Object

Dim xmlDoc As MSXML2.DOMDocument
Dim xmlHttp As MSXML2.XMLHTTP


xmlDoc = New MSXML2.DOMDocument
xmlHttp = New MSXML2.XMLHTTP

requestText = functionToXML(methodName, paramList) ' ok xml
'xmlDoc.loadXML(requestText)

xmlHttp.open
"POST", "https://secure1.revilution.dk/api/index.php", False)
xmlHttp.send(requestText)

we alaways get error in this line: xmlHttp.send(requestText)
Exception Details: System.Runtime.InteropServices.COMException: The
download of the specified resource has failed.
I added MSXML in my referances.
 
D

dado49

This is my asp code.

Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")

requestText = functionToXML(methodName,paramList)

' Call the remote machine the request
objXML.open "POST", "https://secure1.revilution.dk/api/index.php",
false

' This is necessary for some implementations (ZOPE).
objXML.setRequestHeader "Content-type", "text/xml"
objXML.setRequestHeader "Content-lenght", len(requestText)
objXML.setRequestHeader "Connection", "close"
objXML.send(requestText)

serverResponseText = objXML.responseText
..
..
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top