Solved

how to call function in webservice in vb.net 2010

Posted on 2011-03-20
2
865 Views
Last Modified: 2012-05-11
i have included a website in this question. inside the default.aspx.vb is how i called the web service. is this the right way to do or do i have to declare both functions in the service.asmx instead of service.vb in app_code folder? if so how do i call them from asmx file? thank you

note when you run this file please change service.txt to service.asmx. i did that because experts exchange didn't let me upload asmx file. thank you
TemperatureWebService2.zip
0
Comment
Question by:StewSupport
2 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 250 total points
ID: 35177810
check:
http://msdn.microsoft.com/en-us/library/8wbhsy70(v=vs.80).aspx (it has a complete example on temperature conversion)
http://www.w3schools.com/webservices/ws_example.asp

You are trying to call the web service in the same web site as your page. They must be in two separate sites. (First link section: "Adding the Web Service as a Component" shows detail steps on how to consume web service.
0
 
LVL 11

Assisted Solution

by:SAMIR BHOGAYTA
SAMIR BHOGAYTA earned 250 total points
ID: 35177939
Hi, following code is useful to you

Imports System.Web.Services
<System.Web.Services.WebService(Namespace:="http://tempuri.org/ConnectToDatabase/Connect")> _
Public Class Connect
Inherits System.Web.Services.WebService
Public cAdoConn As New ADODB.Connection
Public sConnectString As String
Public gsUserId As String
Public gsPassword As String
Public gsError As String
Dim spath As String
Public Function FunG_ConnectServer(ByVal gsDataSource As String)
sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & gsDataSource
Try
If cAdoConn.State <> 1 Then
cAdoConn.CursorLocation = ADODB.CursorLocationEnum.adUseClient
cAdoConn.ConnectionTimeout = 30
cAdoConn.Open(sConnectString)
End If
Catch ex As Exception
End Try
End Function
End Class
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now