Click to See Complete Forum and Search --> : Calling Web Service from codebehind?
mahivr
Jul 11th, 2005, 01:27 AM
hi
in our project UI project is in Machine1 and web service is in another system.
how can i call the webservice with help of that system's IP address in my asp.net? [without using the webreference or any tool] Is there any way to achieve this with system.net namespace?
Can anybody help me in this context?
mendhak
Jul 11th, 2005, 03:58 AM
Run the wsdl.exe tool:
wsdl.exe /language:VB /out:C:\abc.vb http://XXX.XXX.XXX.XXX/servicename/service.asmx
This will create a proxy class for you. Everytime you want to use a method from there, instantiate it, and use away!
mahivr
Jul 11th, 2005, 05:50 AM
Run the wsdl.exe tool:
wsdl.exe /language:VB /out:C:\abc.vb http://XXX.XXX.XXX.XXX/servicename/service.asmx
This will create a proxy class for you. Everytime you want to use a method from there, instantiate it, and use away!
ok im getting ur point about WSDL. but, if i deployed the UI in one system and WebService in another system(with some modification) how can i access the latest one. i have to recompile my code each time.
mendhak
Jul 11th, 2005, 06:19 AM
Store the URL for the webserver name in a config file. In your proxy class, have the constructor only allow an argument to be passed to it, which would be the name of the webserver picked up from the config file.
mendhak
Jul 11th, 2005, 06:24 AM
Just to clarify, here's an example:
First, I modified the constructor of the proxy class:
Public Sub New(ByVal strWebServiceServer As String)
MyBase.New()
Me.Url = strWebServiceServer & "EmployeeManager.asmx"
End Sub
Then, from my pages, I call it like this:
Dim em As New EmployeeManager(Configuration.ConfigurationSettings.AppSettings("WebServiceServerName"))
mahivr
Jul 11th, 2005, 07:14 AM
Just to clarify, here's an example:
First, I modified the constructor of the proxy class:
Public Sub New(ByVal strWebServiceServer As String)
MyBase.New()
Me.Url = strWebServiceServer & "EmployeeManager.asmx"
End Sub
Then, from my pages, I call it like this:
Dim em As New EmployeeManager(Configuration.ConfigurationSettings.AppSettings("WebServiceServerName"))
i dont know how to create the proxy from my coding and access the webmethods?
mendhak
Jul 11th, 2005, 07:45 AM
Eh? Didn't understand you...
mahivr
Jul 12th, 2005, 01:10 AM
Eh? Didn't understand you...
hi,
i saw one article about using system.net namespace and its classes to call webservice. but im not getting that webarticle now. how can we use system.net namespace to call webservice and methods from codebehind?
mendhak
Jul 12th, 2005, 01:20 AM
What I just showed you does just that. All your calls are from codebehind. If this isn't what you're asking for, show me the article you had seen...
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.