Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Problem using returned data from web service


Problem using returned data from web service

Author
Message
adept710
adept710
Forum God
Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)

Group: Forum Members
Posts: 5, Visits: 12

Hello Everyone,

 

I am having problems with my VB 2008 Express project. Here is a quick outline of what I have done.

 

Used WSDL Tool to create a file named “Racing.vb”.

I then added this file to my project by using Project>Add Existing Item.

This added a file to my Solution Explorer Window named “Racing.vb”

I then searched the new file to find the method I would use to send a web request. This method is copied straight from the Racing.vb file:

 

'''<remarks/>

    <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://direct.tab.com.au/LiveOdds/MeetingSummary", RequestNamespace:="http://direct.tab.com.au/LiveOdds/", ResponseNamespace:="http://direct.tab.com.au/LiveOdds/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>  _

Public Function MeetingSummary(ByVal Key As String, ByVal Jurisdiction As String, ByVal [Date] As String, ByVal TypeCode As String) As System.Xml.XmlElement

        Dim results() As Object = Me.Invoke("MeetingSummary", New Object() {Key, Jurisdiction, [Date], TypeCode})

        Return CType(results(0),System.Xml.XmlElement)

End Function

 

 

          From this I wrote the following code as the request for the web service:

 

 

Dim objMSInfo As New Racing()

Dim MSResult As String

 

MSResult = objMSInfo.MeetingSummary(myKey, strJ, strRD, strTC)

 

 

          As soon as I had finished typing the last line of this code, I got the error message in the Error Box, saying:

 

 

Value of type 'System.Xml.XmlElement' cannot be converted to 'String'.

 

So figuring that the returned values could not be declared as a String, I decided to change my code a little and see if I could return it as an Xml Document, so I changed my code to the following:

 

Dim objMSInfo As New Racing()

Dim MSResult As New XDocument

 

MSResult = objMSInfo.MeetingSummary(myKey, strJ, strRD, strTC)

 

 

          This brings back the same error message, only this time saying:

 

 

Value of type ‘System.Xml.XmlElement’ cannot be converted to ‘XDocument’

 

 

So I am now resigned to asking for the help of someone who has been through this and can see where I am going wrong. I am migrating up from VB4, which I learnt a few years ago now, to VB.Net using the 2008 Express edition, and so I am a bit lost with this Xml Stuff.

 

Oh and for clarification, this is the structure of the data that should be coming back from the MeetingSummary request:

 

 

- <Meetings Jurisdiction="NSW">

- <Summary MID="SR_20040705">

<VenueName>COFFS HARBOUR (NSW)</VenueName>

<Type>R</Type>

<Events>12</Events>

<track>GOOD</track>

<weather>FINE</weather>

             - <Races>

- <Race RID="SR_20040705_01">

<Name>MARES SC PLTE</Name>

<Distance>1200M</Distance>

<Class/>

<RunnerNo Acceptors="14">12</RunnerNo>

<JumpTime>16:52</JumpTime>

<TimeToJump>+03:01:00</TimeToJump>

<RaceStatus>Betting Open</RaceStatus>

</Race>

+ <Race RID=" SR_20040705_2">

+ <Race RID=" SR_20040705_3">

+ <Race RID=" SR_20040705_4">

+ <Race RID=" SR_20040705_5">

+ <Race RID=" SR_20040705_6">

+ <Race RID=" SR_20040705_7">

+ <Race RID=" SR_20040705_8">

+ <Race RID=" SR_20040705_9">

</Races>

</Summary>

+ <Summary MID="MR_20040705">

+ <Summary MID="MH_20040705">

+ <Summary MID="SH_20040705">

+ <Summary MID="BH_20040705">

+ <Summary MID="SG_20040705">

+ <Summary MID="PG_20040705">

+ <Summary MID="MG_20040705">

</Meetings>

 

          Can anyone shed some light on how I can display this information in my program. I intend to declare each element as a variable so that I can display them in a particular way. I can also paste the entire Racing.vb file if needed, however it is a really big file and so for now to save space I will not include it unless needed.

 

          Thanx in advance to anyone who can help guide me with this problem.
TallOne
TallOne
Forum God
Forum God (49K reputation)Forum God (49K reputation)Forum God (49K reputation)Forum God (49K reputation)Forum God (49K reputation)Forum God (49K reputation)Forum God (49K reputation)Forum God (49K reputation)Forum God (49K reputation)

Group: Forum Members
Posts: 370, Visits: 212
Try this...

MSResult = "your code".ToString Or some other available method of that class that converts to string.

TallOne

adept710
adept710
Forum God
Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)

Group: Forum Members
Posts: 5, Visits: 12
Thanx Tallone,

I will give that a go right now and then let you know how it went.

Cheers

adept710
adept710
Forum God
Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)

Group: Forum Members
Posts: 5, Visits: 12
Hi TallOne,

I tried what you suggested, by adding the .ToString method, which was available through the Intellisense thingy, however the error message remained the same.

For some reason, it is not allowing me to declare the returned result as either a String or an XDocument, and I am not sure on where I should be checking to find out what I should be declaring the returned data as.

Any insights? I am truly stumped!

Oh and for clarity, the line I changed was:

Dim objMSInfo As New Racing()

Dim MSResult As String

 

**** This Line below: ****

MSResult = objMSInfo.MeetingSummary(myKey, strJ, strRD, strTC).ToString

 

adept710
adept710
Forum God
Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)

Group: Forum Members
Posts: 5, Visits: 12
Hi TallOne,

Hah, I feel like a fool now. I went back in and declared the result as a String again using:

       Dim objMSInfo As New Racing() 
       Dim MSResult As String

then followed your suggestion again with:

       MSResult = objMSInfo.MeetingSummary(myKey, strJ, strRD, strTC).ToString

and hey presto my error disappeared, so I can only presume that my earlier attempt had an error (my error) in the syntax somewhere.

So thanx again TallOne, that was the solution I think I was looking for, now time to disect the string into relevant variables for my project.

Cheers

Edited
2/18/2009 by adept710
adept710
adept710
Forum God
Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)Forum God (1.9K reputation)

Group: Forum Members
Posts: 5, Visits: 12
Hi everyone,

I am stuck again after using the above code to clear the error in my error box, I then ran the project to see that it was producing the right results.

I modified the earlier code again by adding the following line:

    Dim objMSInfo As New Racing()

    Dim MSResult As String

 

    MSResult = objMSInfo.MeetingSummary(myKey, strJ, strRD, strTC).ToString

 

and then I added this following line:

 

    OutputTextBox.Text = MSResult

 

 

Now I am getting text displayed in the textbox, except instead of the text showing the structure of the results above in one string, it simply returns the following in the text box:

 

    "System.Xml.XmlElement"

 

Can anyone shed any light on why it is returning this result and not the structure as outlined in the original post? And also how I should approach this problem?

 

Cheers and Thanx in Advance.


GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search