Window app calling a web service.

mike55

Contributor
Joined
Mar 26, 2004
Messages
727
Location
Ireland
Hi,

I have created a web service that is responsible for accessing an SQL database collecting the data and then processing it in an appropriate manner.

I have a windows application that then acts as a front-end which is responsible for calling the web method in the web service.

I have added a reference to my windows application for the web service and have created an instance of it in the same manner as if it was a web application accessing a web service:
Code:
dim ws as new wsSendMsg.wsSendMessages

However when I go
Code:
ws.startProcessing() 'The webmethod on the web service.
I get a Http error: Http error 401 Unauthorized, access denied. Searches on the internet suggest that I must pass authentication information to the web service. My question is what authentication information and how do I pass that information.

Mike55
 
Ok,

This is what I have found out so far, basically for a windows app to access as web service on the same machine it is necessary for the window app to pass the necessary credenticals to the web service. Therefore, just before you call the web method you call the following line of code:
Code:
ws.Credentials = System.Net.CredentialCache.DefaultCredentials
Where ws is equals to:
Code:
Dim ws As New wsSendMsg.wsSendMessages

Mike55
 
Back
Top