Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This is an XML forum, correct?

 

I wish I knew what the criteria was for either responding to a post or ignoring them. I posted an xml question on 3/25/05...not one response. I did ask anyone to do my programming for me, I just asked for some direction.

 

This was the origional question...

------------------------------------

I have to learn how to use .Net to not just work with xml documents, (that exist, or that I create through VBNET), but also how to do requests to get data from other then existing xml documents, (using a xml query external file), and validate that request\response. I think that I have to use MSXML, and somehow pass the xml query to it, and then check the results.

 

Where can I learn to do this. I am using VB .net 2003.

-----------------------------------------------------------------------

 

I will expand on the question. I am not sure that DOM, and/or MSXML is the best, or latest technology. What is? Some information points me to Web Services. That confuses me. I need to create a Web Service to pass XML requests and responses back and forth between servers?

 

These is a lot of dicumentation on dealing with the creation of an XML document, and, reading from an XML document. There is basically no documentation on how to send a request, and get a response, to and from another server.

 

Thanks

 

Lou

  • *Experts*
Posted

I'm guessing no one responded because your question makes me ask more questions :)

 

First, what do you mean by sending "XML requests"? XML is just a specific way to format text, at it's core. There are certain standards that rely on XML, but XML doesn't really do anything by itself.

 

For example, SQL Server can interpret XML as a table. If you're using SOAP, which is a protocol - a standard for sending messages, then the "SOAP request" is formatted as XML. A DataSet can be viewed as XML.

 

As for working with XML as an object model in .NET, you will most often use the XmlDocument object, part of the System.Xml namespace. You could use MSXML2 but it would go through the COM wrapper. I hear its transforms are a lot faster, but there are issues (COM being one, security being another).

 

There are other objects in the System.Xml namespace that you might use, depending on your needs.

 

Also, questions like "I need help learning Xml" often go unanswered simply because most people would expect you to search google and look for tutorials first. The questions that get the best answers are those that ask specific questions. For instance, "Which object would/should I use to load an XML file from disk and work with it in such-and-such way?".

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

XML questions

 

I'm guessing no one responded because your question makes me ask more questions :)

 

Ner

 

I had spent hours searching the web for what I was looking for. I was not in any way, shape, or form...looking for a free ride. It perterbs me when those who have the knowledge, want everyone to learn the hard way.

 

Yes, the internet abounds with examples of creating XML files, reading xml files, using xml to and from SQL databases, etc. I can find very little documentation on Using a URL to send a request through a SOAP wrapper\envelope across to another server, and then handle the response back to the requesting server, (using VB. Net).

 

I have something that works, but not exacly correct, and I was looking for other examples, or direction to what is the newest, and/or more correct way to do this...

------------------------------------------------------------------

Dim XmlRequestDoc, XmlResponseDoc

Dim XmlRequest, XMLResponse As String

 

Dim XmlHttp

Dim URL ="http://,,,,,"

XmlRequestDoc = CreateObject("msxml2.domdocument")

XmlResponseDoc = CreateObject("msxml2.domdocument")

 

OpenXmlFile()

 

XmlRequestDoc.loadXML(XmlRequest)

 

'XmlHttp = CreateObject("microsoft.xmlhttp")

XmlHttp = CreateObject("MSXML2.sERVERxmlhttp.3.0")

XmlHttp.open("post", URL, False, "USername", "Password")

' Set request headers.

XmlHttp.setRequestHeader("Content-Type", "text/xml")

XmlHttp.setRequestHeader("Content-Length", "" & Len(XmlRequest))

Try

XmlHttp.send(XmlRequestDoc)

Do While XmlHttp.readyState < 4

System.Windows.Forms.Application.DoEvents()

Loop

XMLResponse = XmlHttp.responsetext

'MessageBox.Show(XmlRequest + " ***" + XMLResponse)

'XmlResponseDoc.loadxml(XmlHttp.responsetext)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End

 

Sub OpenXmlFile()

Dim fso, f, ts

Dim s As String

Dim i

fso = CreateObject("Scripting.FileSystemObject")

f = fso.getfile("getproperties.xml")

ts = f.OpenAsTextStream(1, -2)

XmlRequest = ts.readAll

-------------------------------------------------------------------

There...while it may not be perfect, I am quite willing to show and give to someone else.

Lou

Posted

OMG, that looks like ASP code, am I right?

ok, here's a simple example on how I read a really really small XML I used in my app for the database configuration

 

public string fnXmlDB()
{
    string s_path="";
    try
    {
         XmlTextReader reader = new XmlTextReader("DbConfig.xml");
         while(reader.Read())
         {
              if(reader.Name=="dbpath")
              {
                   s_path= reader.ReadString();
              }
         }
    }
    catch
    {
         s_path = "";
    }
    return s_path;
}

Fat kids are harder to kidnap
Posted

XML code

 

OMG, that looks like ASP code, am I right?

ok, here's a simple example on how I read a really really small XML I used in my app for the database configuration

 

Iebidan

 

Thanks for your reply.

 

Is what I posted ASP? Since I am not an ASP person, I will have to take your word for it.

 

What you have posted is how to loop through am xml file. I am looking for sending a request using a URL, from one server to another, using XML, (probably wrapped in SOAP), in VB .NEt code.

 

Lou

Posted

Could you be a lot more specific ?

Explain to all of us what you really want to do.

(By the way... don't make us work on an entire project that you haven't gotten into enough to understand it, right ? :D)

 

What exactly do you want to know about XML document ?

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted
Could you be a lot more specific ?

Explain to all of us what you really want to do.

(By the way... don't make us work on an entire project that you haven't gotten into enough to understand it, right ? :D)

 

What exactly do you want to know about XML document ?

 

Arch4ngl

 

The comment 'don't make us work on an entire project ', was totally uncalled for! First I have specifically stated that I am not looking for anyone to write my code! Secondly, I have stated that I am not looking for help with either creating or reading an XML document. Third, I have stated that I am looking for help\direction on how to, (by using a URL), send a request and recieve a response using DCOM\MSXML\Web Services\whatever. I even included a sample of code, that I am trying to determine if it is the right way of doing the send and recieve, (are there more current\better ways of doing this?).

 

How much more clearer can I be!

 

Help me...do not jerk me!

Posted

If you know how to send data through a WebService...

Load the XML file in a XmlDocument and send the object through the WebService.

 

Sorry for my comment! ;) It's was only a joke that didn't were welcome.

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

I'm not quite sure that you'll be able to send a request thru an URL, but maybe I'm wrong, what you can actually do, if you don't want to read the XML before the load of the page using CodeBehind, my suggestion is to use WEBSERVICE BEHAVIOR, I used it in an application the address is:

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/overview.asp

With this you'll be able to call a webservice from the client side and you'll be able to read the result of the webservice using jscript, if this is not what you're looking for then you can read about SOAP, the address for an article is:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsoap/html/understandsoap.asp

 

I hope this is what you're looking for, if not I will be like Nerseus, I don't understand what you're looking for, BTW where in the world is located Longueuil?????

Fat kids are harder to kidnap
Posted

Web Services

 

If you know how to send data through a WebService...

Load the XML file in a XmlDocument and send the object through the WebService.

 

Sorry for my comment! ;) It's was only a joke that didn't were welcome.

 

If I understand your reply correctly, you are saying that the current\newest technology for what I want to do, is to use Web Services?

 

What little I know about Web Services, (nothing, and I will learn it if there are examples out there), is that it was for creating a Web Service, and then using that Web Service.

 

So..my limited understanding of what you just said, is that I will first have to create my own Web Service, and then use it to do the XML requests and responses. Or...or you talking about some existing Web Service that I should use?

 

Thanks

 

Lou

  • *Experts*
Posted

As I said in the first post, I wasn't sure what you really wanted and what you have. A "request" can take on many meanings...

 

Let's assume you have some DLL on a server that you need to "call" into - your request. The "normal" way in .NET is to use remoting or a web service. These are the two most common ways to make a server to server call (or client to server in most cases). Web services use SOAP to communicate. SOAP is just a protocol, like HTTP. A protocol being a standard way that servers might communicate. You *could* make a SOAP call yourself. Basically build up the correct XML and send it using some tools (MS provides a SOAP toolkit which uses COM components).

 

If you use webservices, this is all done for you. If you know how to setup a website and .NET code, you're halfway there. You'll want to look at creating an ASMX page (a webpage that exposes methods of a class). From your Visual Studio project you can right click on "Web References" (just below References in your project) and select Add.

 

There's obviously a lot more to all this than what I've got, but it should get you started. A good book on webservices might help a lot. Many used ones can be found on Amazon for $10 or less. Then there's always MSDN for some other info.

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

I just needed to use the latest stuff, (Web Services not needed)

 

I have gotten an error free response back by using the latest versions of the same methods that I was using before....

 

Imports System.xml

Imports System.io

 

Module Module1

Dim XmlRequest, XMLResponse As String

 

Sub Main()

Dim http As MSXML2.ServerXMLHTTP40 = New MSXML2.ServerXMLHTTP40

Dim Requestdoc As MSXML2.DOMDocument40 = New MSXML2.DOMDocument40

Dim Responsedoc As MSXML2.DOMDocument40 = New MSXML2.DOMDocument40

Const Service_URL = "http://dctm-...."

Dim mResStr As String

 

Try

'Load soap\xml from file into string

OpenXmlFile()

'load the string into the request document

Requestdoc.loadXML(XmlRequest)

 

'prep the http

http.open("POST", Service_URL, False, "user", "password")

http.setRequestHeader("Content-Type", "text/xml")

http.setRequestHeader("Content-Length", "" & Len(XmlRequest))

 

'send the request

http.send(Requestdoc)

'get the response

'MsgBox(http.responseText)

'Responsedoc.loadXML(http.responseText)

mResStr = http.responseText

Catch ex As Exception

MsgBox(ex.Message)

End

End Try

 

 

End Sub

 

Sub OpenXmlFile()

Dim fso, f, ts

Dim s As String

Dim i

fso = CreateObject("Scripting.FileSystemObject")

f = fso.getfile("getproperties.xml")

ts = f.OpenAsTextStream(1, -2)

XmlRequest = ts.readAll

End Sub

 

End Module

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...