Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hi,
i would consume a web service in windows service.
the following code work right in windows form, but fails on windows service
Dim myservice As servicenamespace.serviceclass
myservice =new servicenamespace.serviceclass
Dim return_string As String =myservice.method("")



i don't obtain any exceptions.
can you help me?
thanks
Posted
Comments
Afzaal Ahmad Zeeshan 11-May-15 6:55am    
Is your Windows Service a client?
gregorio89 11-May-15 7:02am    
i run the windows service from a client.
Herman<T>.Instance 11-May-15 7:03am    
you don't. A Windows Service does it's task, but cannot be 'queried' for or connected to to get an answer. You need a WebAPI or something similar.
gregorio89 11-May-15 7:10am    
so i can't use a windows service to get an answer from a web service?
Herman<T>.Instance 11-May-15 7:27am    
Sorry. Misunderstood you. You can add a Service Reference (right mouse click on 'References' in Solution Explorer

1 solution

You can add a Service Reference (right mouse click on 'References' in Solution Explorer
 
Share this answer
 
Comments
gregorio89 11-May-15 7:52am    
already done it.
with the code that I posted,
I can obtain the web service result on a windows form application.
the same code doesn't work on windows service.
I think this isn't so simple on windows service.
Herman<T>.Instance 11-May-15 8:15am    
I cannot see your Windows Service Code.
In each class you have to instantiate your service reference unless you use containering like Unity
Does your Service has the appropriate rights to connect the webapi?
gregorio89 11-May-15 8:19am    
Can you show me an example?
I have consumed with success the web service in windows form.
I don't know if I need something different with Windows service.
Herman<T>.Instance 11-May-15 9:05am    
do you have created a debuggable windows service?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900