Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do a Web Reference via Code

Status
Not open for further replies.

tdtomlins

Programmer
Sep 20, 2002
6
US
Any suggestions on on to add a reference to a clients machine to a web service (Web Reference) by code. I'm experimenting with writting a client front end with a web location on the database side. I almost have it done but I will need to have the user select the location of the "Web Reference" for my code to reference the corret web Service.

Any suggestions. I havn't een been able to self reference a DLL via .NET yet.

When I find It I'll Post the answer.

Thanks
Tomlins
 
Once I found the answer it was easy when you Reference your Web services change it to Dynamic and don't use LocalHost change it to a normal URL.

In code you reference your Web Reference normally like Public ws as NEW WebRef.Service()

To change the reference location you just type in
ws.URL = "Your URL" & "/Service1.asmx"

That's it I havn't figured out a quick way to check the connection without doing the following (which is a timeout routine)

Public Function CheckWSConnection() as boolen
Dim ws as new WebRef.Service()
'The default timeout is 60 sec.
'You can change this by doing ws.timeout = 30 'refers to 30 sec. I wasn't able to get this to change.

Dim strTemp As String
Try
strTemp = ws.ServerTime.ToString
'Obtained data from the Web Service
return True
Catch
'Couldn't get Connection
return False
End Try

End function

Hope this information save someone some time.
Tomlins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top