AMB Posted March 27, 2012 at 09:42 AM Report #445856 Posted March 27, 2012 at 09:42 AM Bom Dia a todos Desculpem desde já a minha ignorância no que diz respeito aos webservices... O que eu tenho de fazer é um web service que ou execute um bat ou redirecione para uma pagina web consoante existe dados em sql ou não. O código para isto eu já tenho, mas não consigo que ele abra a pagina quando o executo. Apenas aparece o link em xml... Qual a asneira que estou cometendo??? Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel Imports System.Data.SqlClient ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' <System.Web.Script.Services.ScriptService()> _ <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _ <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <ToolboxItem(False)> _ Public Class Service1 Inherits System.Web.Services.WebService <WebMethod()> _ Public Function nleitura() As String Dim conne As String Dim x As String = "92414" Dim nleitura1 As String Dim nleiturat As String conne = "Data Source=localhost;Initial Catalog=bd;Integrated Security=True" Dim conn As New SqlConnection Dim comand As New SqlCommand conn.ConnectionString = conne conn.Open() comand.Connection = conn comand.CommandText = "SELECT Processo FROM pacs WHERE Processo ='" & x & "'" nleitura = comand.ExecuteScalar If nleitura Is Nothing OrElse IsDBNull(nleitura) Then Return "Erro nº processo" Else comand.CommandText = "SELECT Imagens FROM pacs WHERE Processo ='" & x & "'" nleiturat = comand.ExecuteScalar If nleiturat Is Nothing OrElse IsDBNull(nleiturat) Then Return "Não existe jnlp" System.Diagnostics.Process.Start("C:\find\" + x + ".bat") System.Diagnostics.Process.Start("C:\" + x + ".bat") Return "http://pm/web/imagens/" + x + ".jnlp" Else Dim conne1 As String conne1 = "Data Source=localhost;Initial Catalog=bd;Integrated Security=True" Dim conn1 As New SqlConnection Dim comand1 As New SqlCommand conn1.ConnectionString = conne1 conn1.Open() comand1.Connection = conn1 comand1.CommandText = "SELECT accno FROM study WHERE accno='" & x & "'" nleitura1 = comand1.ExecuteScalar If nleitura1 Is Nothing OrElse IsDBNull(nleitura1) Then System.Diagnostics.Process.Start("C:\" + x + ".bat") Return "http://pm/web/imagens/" + x + ".jnlp" Else Return "http://pm/web/imagens/" + x + ".jnlp" End If End If End If End Function End Class
petvetbr Posted March 27, 2012 at 10:25 AM Report #445869 Posted March 27, 2012 at 10:25 AM O código está certo. Um WebService geralmente retorna dados como XML ou json. Cabe a você receber estes dados no cliente e exibi-lo corretamente para isto é necessário usar JavaScript na página que faz a chamada para extrair os dados da resposta do serviço e exibi-lo de uma forma adequada como um link neste caso. Fernando Lage Bastos - MCP/MCTS/MCPD
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now