locked
svcutil.exe Creazione di un client scaricando dati da servizio in esecuzione RRS feed

  • Domanda

  • Si abbia il seguente codice visul basic come modulo di un progetto di nome Anagrafe1 in una soluzione di nome Anagrafe1:

    Imports System.ServiceModel
    Imports System.ServiceModel.Description
    Module Module1
        <ServiceContract(Namespace:="http://Anagrafe1")> _
        Public Interface ILocalità
            <OperationContract(IsOneWay:=False)> Function Immetti(objRecLoc As String) As String
            <OperationContract(IsOneWay:=False)> Function Ricerca(objrecloc As String) As String
          End Interface

        Public Class Località
            Implements ILocalità
            Public Function Immetti(objRecLoc As String) As String Implements ILocalità.Immetti
                Try
                    Immetti = "La nuova località è stata immessa "
                Catch e As Exception
                    Immetti = "Errore di Run Time: " + e.Message
                End Try
            End Function
            Public Function Ricerca(objrecloc As String) As String Implements ILocalità.Ricerca
                Return objrecloc
            End Function
        End Class
      

      Sub Main()
            Dim BaseAddress As Uri = New Uri("http://localhost:8080/Anagrafe1")
            Dim AnagrafeHost As New ServiceHost(GetType(Località), BaseAddress)
            Try
                AnagrafeHost.AddServiceEndpoint(GetType(ILocalità), New WSHttpBinding, "Località")
                Dim SMB As New ServiceMetadataBehavior() : SMB.HttpGetEnabled = True
                AnagrafeHost.Description.Behaviors.Add(SMB)

                AnagrafeHost.Open()
                MsgBox("Il servizio Anagrafe è aperto!" + vbCrLf + "Premere OK per chiudere")
                AnagrafeHost.Close()
            Catch ce As CommunicationException
                MsgBox(ce.Message)
                AnagrafeHost.Abort()
            End Try
        End Sub
    End Module

    Tale progetto viene completamente compilato ed eseguito in VS. Tuttavia da esso non è possibile ottenere i metadati da riga di comando con l' App SvcUtil.exe. Perchè?

    giovedì 5 settembre 2019 15:36