Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/06/2015, 01:10
wwwmaster
 
Fecha de Ingreso: noviembre-2002
Ubicación: DF
Mensajes: 1.056
Antigüedad: 21 años, 5 meses
Puntos: 37
Respuesta: Como acceder a un servicio Web Utilizando WebClient c#

No he usado AXIS.

pero para la autenticacion debieron proporcionarte un usuario y pwd.
Por lo de SSL, pues seguramente el URL a donde te conectaras tendra el protocolo "https", algo como:

linkdelwebservice = "https://dominio.com/api/login/webservice01"
Dim wbrq As HttpWebRequest = HttpWebRequest.Create(enlaceKPI)
wbrq.ContentType = "application/json; charset=utf-8"

(te tienen q decir en q formato viene la respuesta, si json o xml )
tambien si la conexion o envio de parametros (usuario y pwd es por GET o POST)

SI ES POR GET
wbrq.Method = "GET"
'Get the headers associated with the request.
Dim myWebHeaderCollection As WebHeaderCollection = wbrq.Headers
myWebHeaderCollection.Add("sessionId", sessionID) ' En mi caso me mandan un session ID luego del login
Dim RequestHttpHeaders As NameValueCollection = New NameValueCollection()

SI ES POR POST:
wbrq.Method = "POST"

'Get the headers associated with the request.
Dim myWebHeaderCollection As WebHeaderCollection = wbrq.Headers
myWebHeaderCollection.Add("sessionId", sessionID)
Dim RequestHttpHeaders As NameValueCollection = New NameValueCollection()

wbrq.Accept = "application/json"
wbrq.UserAgent = ".NET Framework Test Client"

ASI ES COMO MANDO EL USUARIO Y PWD, lo piden ademas como JSON:

dictionary.Add("username", usuarioquemedieron)
dictionary.Add("password", pwd)

jsonData = New JavaScriptSerializer().Serialize(dictionary)

wbrq.ContentLength = jsonData.Length
Dim s As StreamWriter = New StreamWriter(wbrq.GetRequestStream()) 'Cannot send a content-body with this verb-type
s.Write(jsonData)

s.Close()


RECUPERO LA RESPUESTA, en mi caso como CADENA:
Dim wbrs As HttpWebResponse = wbrq.GetResponse

stream = New StreamReader(wbrs.GetResponseStream, Encoding.GetEncoding("utf-8"))

Dim JSON_respuestaDELWS As String = ""
JSON_respuestaDELWS = stream.ReadToEnd.Trim