Someone, can illustrate a simple source code to use SOAPMetodh? I invoke a service that returns more than one result (a list) and i read the first fine, but i have no idea how to navigate to read other values. If i use a service that returns a single record it’s all right, i find problems to read a complex xml more records as result.
Service i’m using is THIS
Thanks for help and ideas.[h]soap xml documentation[/h]
Which method on that service are you trying to call? What does your code look like?
My code is very simple:
Dim sm As New SOAPMethod(“http://www.webservicex.net/medicareSupplier.asmx?WSDL”)
dim sr as new SOAPResult
sm.Parameter(“City”)=“New York”
sr= sm.Invoke(“GetSupplierByCity”)
msgbox sr.Result(“CompanyName”)
dim s as string
s= sr.Result(“GetSupplierByCityResponse”)
Msgbox returns the first company name but after it, i see into the xml (s variable), others company name and i don’t know as showing them.
enough is also a link to study …
Thanks again
The results are mostly XML. I had to strip off part of it to get it to load into an XMLDocument. This code displays all the company names in a ListBox:
Dim sm As New SOAPMethod("http://www.webservicex.net/medicareSupplier.asmx?WSDL")
Dim sr As New SOAPResult
sm.Parameter("City") = "New York"
sr = sm.Invoke("GetSupplierByCity")
Dim s As String
s = sr.Result("GetSupplierByCityResponse")
// Strip off <GetSupplierByCityResult> section as it messes up the XML
Dim pos As Integer
pos = s.InStr("<SupplierDataLists ")
// Add XML prefix so XML loads properly
s = "<?xml version=""1.0""?>" + s.Right(s.Len-pos+1)
Dim xml As New XmlDocument
Try
xml.LoadXml(s)
Catch e As XmlException
ErrorArea.Text = e.Message
End Try
Dim data As XmlNodeList
// Find all company names in the XML
data = xml.Xql("//CompanyName")
ListBox1.DeleteAllRows
// Loop through results and display them in a ListBox
Dim item As XmlNode
For i As Integer = 0 To data.Length-1
For j As Integer = 0 To data.Item(i).ChildCount-1
item = data.Item(i).Child(j)
ListBox1.AddRow(item.Value)
Next
Next
Fantastic Paul, it runs. Now i will study that.
I am trying the same, but i fail. As soon as i call the Invoke, the debugged App crashes (Mac OS X 10.8.x).
I had some limited success implementing a UPnP Network Gateway Device… (Lots of SOAP.)
but never finished the project…