Page 1 of 1

call webService by vb .Net

PostPosted:Fri Jul 22, 2011 9:50 am
by tgarijo
Hi to all and thank you

I have a web reference name OKMAuthService i

Mi code for login to openKm is

but the i have a this exception in line _stoken = openKMAuth.login("user", "pass")

Code: Select all
System.Net.WebException was unhandled
  Message=The underlying connection was closed: An unexpected error occurred on a receive.
  Source=System.Web.Services
  StackTrace:
       at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
       at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at Expe.OKMAuthService.OKMAuthService.login(String user, String password) in C:\PIG\Proyecto\Expe.NET\Web References\OKMAuthService\Reference.vb:line 413
       at Expe.cl_OpenKm.Login(String user, String password) in C:\PIG\Proyecto\Expe.NET\Classes\openKm\cl_OpenKm.vb:line 22
       at Expe.Database.FrmMDIExpedientacion.FrmMDIExpedientacion_Load(Object eventSender, EventArgs eventArgs) in C:\PIG\Proyecto\Expe.NET\Forms\FrmMDIExpedientacion.vb:line 524
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, Int32 wParam, Int32 lParam)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Expe.Database.FrmMDIExpedientacion.Main() in C:\PIG\Proyecto\Expe.NET\Forms\FrmMDIExpedientacion.vb:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.IOException
       Message=Unable to read data from the transport connection: Se ha forzado la interrupción de una conexión existente por el host remoto.
       Source=System
       StackTrace:
            at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
            at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
            at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
       InnerException: System.Net.Sockets.SocketException
            ErrorCode=10054
            Message=Se ha forzado la interrupción de una conexión existente por el host remoto
            NativeErrorCode=10054
            Source=System
            StackTrace:
                 at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
                 at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
            InnerException: 
this is my code its very simple
Code: Select all
Public Class cl_OpenKm
    Private _stoken As String

    Public openKMAuth As OKMAuthService.OKMAuthService

    Public Sub New()
        openKMAuth = New OKMAuthService.OKMAuthService
    End Sub

    Public Sub Login(ByVal user As String, ByVal password As String)
        _stoken = openKMAuth.login("user", "pass")
    End Sub

    Public Sub Logout(ByVal user As String, ByVal password As String)
        openKMAuth.logout(_stoken)
    End Sub

    Public ReadOnly Property stoken As String
        Get
            Return _stoken
        End Get

    End Property
End Class

Re: call webService by vb .Net

PostPosted:Fri Jul 22, 2011 11:01 am
by jllort
I suggest you take a look at our ms ws library project at http://openkm.svn.sourceforge.net/viewv ... penKMCore/

Re: call webService by vb .Net

PostPosted:Fri Jul 22, 2011 11:18 am
by tgarijo
Its solved.

I replace

' Me.Url = Global.Expe.My.MySettings.Default.Expe_OKMAuthService_OKMAuthService

by

Me.Url = "http://192.168.3.116:8080/OpenKM/OKMAuth"

in class OKMAuthService

Thank You