calling a web service

Roba

New member
Joined
Oct 21, 2009
Messages
3
Location
Beirut,Lebanon
Programming Experience
Beginner
i want to call a web service in my vb.net project but i'm having this error
(i'm a new developper ,if you need any more information plz do ask )

System.Web.Services.Protocols.SoapException was unhandled
Actor="DefaultRole"
Lang=""
Message="Internal Error"
Node="DefaultRole"
Role=""
Source="System.Web.Services"
StackTrace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Apptest.InsuranceService.Insurance.AddVehicleInsurance(InsuranceInfoType InsuranceInfo) in C:\Users\Roba\Documents\Visual Studio 2008\Projects\Apptest\InsuranceService.vb:line 48
at Apptest.Form1.Button2_Click(Object sender, EventArgs e) in C:\Users\Roba\Documents\Visual Studio 2008\Projects\Apptest\Form1.vb:line 73
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
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(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Apptest.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly 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)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:


this is my code :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim sr As New InsuranceService.Insurance
Dim req As New InsuranceService.InsuranceInfoType
Dim res As New InsuranceService.InsuranceInfoResponse
Dim ncred As New NetworkCredential("InsuranceCompany", "insurance")


Dim store As New X509Store(StoreName.Root, StoreLocation.LocalMachine)
store.Open(OpenFlags.[ReadOnly])
Dim col As X509Certificate2Collection = store.Certificates.Find(X509FindType.FindBySerialNumber, "4ad5837b", True)

System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Ssl3
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateServerCertificate)

sr.ClientCertificates.Add(col(0))
sr.Credentials = ncred
req.PolicyNumber = "1111"
req.PolicyType = InsuranceService.InsuranceTypeValues.Comprehensive
req.PolicyDate = Convert.ToDateTime("2009-12-20+04:00")
req.PolicyExpiryDate = Convert.ToDateTime("2009-12-20+04:00")
req.InsuranceCompanyNumber = 63750
req.ChasisNumber = " dadad"
req.ModelYear = 2009
req.EngineNumber = "sjf86549"
res = sr.AddVehicleInsurance(req) 'the error is generated at this line
MsgBox(res.Status)


End Sub
Public Shared Function ValidateServerCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
Return True
End Function
 
Back
Top