Credentials Property Missing From WebService Instance


You are eating your liver because you have created an Instance of a Web Service which exists in your local project and you want to add custom Credentials to the proxy Instance BUT there is no Credentials property.

So Pretty, So Useless

Your code looks flawless: It looks something like this, but Visual Studio reports there is no Credentials property

_MyWebService = New XMLExtractWebService

What You Need To Do

Add a Web Reference to the Web Service i.e. Click on the WebReferences folder in the project which is consuming the Web Service and select Add Web Reference. Click on ‘Web Services In This Solution’ and then select your Web Service. Add a Reference name for it. I called my reference MyXMLExtractWebService.

Now update your code as follows, giving the class name of your Web Reference:

_MyWebService = New MyXMLExtractWebService.XMLExtractWebService

Your Credentials Property is now there.

Why It Works

The Credentials Property only exists on Web Services deriving from created using the Web Services Description Language (WSDL) tool (Wsdl.exe), or created when adding a Web Reference in Visual Studio.NET,

These Web Services derive from the SoapHttpClientProtocol class and have a Credentials property, which can be used to get or set security credentials for Web Service client authentication.

For this wisdom we can thank Madhu in this post in the .NET 247 Forum


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: