Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    451

    lettura System.Xml.XmlNode

    Sto uscendo pazzo... come posso leggere i valori che ritorno da una function come questa???

    codice:
            Public Function GetNews(ByVal n As String) As System.Xml.XmlNode
                Return MyBase.Channel.GetNews(n)
            End Function
    ho provato a trattarlo come un xml ma va solo in errore

    ho provato varie tecniche per l'xml e questo è l'ultimo errore che mi è ritornato

    codice:
    Error	8	Overload resolution failed because no accessible 'Load' can be called with these arguments:
        'Public Overridable Sub Load(reader As System.Xml.XmlReader)': Value of type 'System.Xml.XmlNode' cannot be converted to 'System.Xml.XmlReader'.
        'Public Overridable Sub Load(txtReader As System.IO.TextReader)': Value of type 'System.Xml.XmlNode' cannot be converted to 'System.IO.TextReader'.
        'Public Overridable Sub Load(inStream As System.IO.Stream)': Value of type 'System.Xml.XmlNode' cannot be converted to 'System.IO.Stream'.
        'Public Overridable Sub Load(filename As String)': Value of type 'System.Xml.XmlNode' cannot be converted to 'String'.
    Mi dice persino di trasformarla in una string.... ma come faccio se io ho la necessità di recuperare alcuni valori?

    Grazie.

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2011
    Messaggi
    119
    Con la funzione così da sola non si capisce proprio niente.
    Quello che devi mostrare è tutto il blocco dall'apertura del file xml alla lettura e ovviamente la funzione.

  3. #3
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    451
    sto studiando le webservices quindi il codice che sto utilizzando è questo:

    http://webservices.dotnethell.it/WSContents.asmx

    codice:
    Namespace dotnethell
        
        <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0"),  _
         System.ServiceModel.ServiceContractAttribute([Namespace]:="http://webservices.dotnethell.it/WSContents", ConfigurationName:="dotnethell.WSContentsSoap")>  _
        Public Interface WSContentsSoap
            
            <System.ServiceModel.OperationContractAttribute(Action:="http://webservices.dotnethell.it/WSContents/GetAllTips", ReplyAction:="*"),  _
             System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults:=true)>  _
            Function GetAllTips(ByVal userid As String, ByVal password As String) As System.Xml.XmlNode
            
            <System.ServiceModel.OperationContractAttribute(Action:="http://webservices.dotnethell.it/WSContents/GetArticles", ReplyAction:="*"),  _
             System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults:=true)>  _
            Function GetArticles(ByVal n As String) As System.Xml.XmlNode
            
            <System.ServiceModel.OperationContractAttribute(Action:="http://webservices.dotnethell.it/WSContents/GetNews", ReplyAction:="*"),  _
             System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults:=true)>  _
            Function GetNews(ByVal n As String) As System.Xml.XmlNode
            
            <System.ServiceModel.OperationContractAttribute(Action:="http://webservices.dotnethell.it/WSContents/GetTips", ReplyAction:="*"),  _
             System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults:=true)>  _
            Function GetTips(ByVal n As String) As System.Xml.XmlNode
        End Interface
        
        <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")>  _
        Public Interface WSContentsSoapChannel
            Inherits dotnethell.WSContentsSoap, System.ServiceModel.IClientChannel
        End Interface
        
        <System.Diagnostics.DebuggerStepThroughAttribute(),  _
         System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")>  _
        Partial Public Class WSContentsSoapClient
            Inherits System.ServiceModel.ClientBase(Of dotnethell.WSContentsSoap)
            Implements dotnethell.WSContentsSoap
            
            Public Sub New()
                MyBase.New
            End Sub
            
            Public Sub New(ByVal endpointConfigurationName As String)
                MyBase.New(endpointConfigurationName)
            End Sub
            
            Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
                MyBase.New(endpointConfigurationName, remoteAddress)
            End Sub
            
            Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
                MyBase.New(endpointConfigurationName, remoteAddress)
            End Sub
            
            Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
                MyBase.New(binding, remoteAddress)
            End Sub
            
            Public Function GetAllTips(ByVal userid As String, ByVal password As String) As System.Xml.XmlNode Implements dotnethell.WSContentsSoap.GetAllTips
                Return MyBase.Channel.GetAllTips(userid, password)
            End Function
            
            Public Function GetArticles(ByVal n As String) As System.Xml.XmlNode Implements dotnethell.WSContentsSoap.GetArticles
                Return MyBase.Channel.GetArticles(n)
            End Function
            
            Public Function GetNews(ByVal n As String) As System.Xml.XmlNode Implements dotnethell.WSContentsSoap.GetNews
                Return MyBase.Channel.GetNews(n)
            End Function
            
            Public Function GetTips(ByVal n As String) As System.Xml.XmlNode Implements dotnethell.WSContentsSoap.GetTips
                Return MyBase.Channel.GetTips(n)
            End Function
        End Class
    End Namespace
    e l'xml

    codice:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <GetNews xmlns="http://webservices.dotnethell.it/WSContents">
          <n>string</n>
        </GetNews>
      </soap:Body>
    </soap:Envelope>
    nella form
    codice:
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim prova As New dotnethell.WSContentsSoapClient
            prova.GetNews(1) ' A questo punto non so come poter leggere il dato
        End Sub
    Come dovrei trattare i dati che ricevo??? Ho capito che vanno usate come normali function ma non capisco come devo leggere in particolare quel dato di ritorno.

    Grazie.

  4. #4
    Il titolo della discussione non è conforme al regolamento, mandami per favore un messaggio privato con la rettifica.
    Chi non cerca trova.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.