954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Consuming a web service with proxy settings

I am trying to consume a web service using VS2008.

The code below works in VS2005 but not VS2008 I, suspecting it's to do with WCF. Please can someone help me to solve the puzzle?

'Old code that works

Dim o As New MyWebService.Name
        Dim pr As New System.Net.WebProxy("100.0.1.1", 80)

        pr.Credentials = System.Net.CredentialCache.DefaultCredentials
        o.Proxy = pr

        Dim ds As New DataSet
        ds = o.GetMyData(Me.TextBox1.Text, "password")
        Me.DataGridView1.DataSource = ds.Tables(0)

This is how im trying to do it with no success

Dim o As MyWebService.nameSoapClient = New MyWebService.nameSoapClient()
        o.ClientCredentials = System.Net.CredentialCache.DefaultCredentials.GetCredential('lost here')

        DataGridView1.DataSource = o.GetMyData(Me.TextBox1.Text, "password")
k1robert
Newbie Poster
20 posts since Feb 2010
Reputation Points: 10
Solved Threads: 1
 
o.ClientCredentials.UserName.UserName="user"
o.ClientCredentials.UserName.Password ="password"


Take a look at msdn article - http://msdn.microsoft.com/en-us/library/system.servicemodel.description.clientcredentials.username.aspx

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

It turns out i could have continued using the original code. But when adding a Web service to a windows application using VS 2008 there's a bit of a change.

When you go to add a web reference (by right clicking on your project then add Service Reference) you are prompted to add a "Service Reference" in VS 2008. Once you have done this you will see an advanced button below click on it. Now put your wsdl link in and press go. Make sure you give your web reference a meaning full name "MyWebService"and then click on Add Reference.

You can now use the code in the original thread

k1robert
Newbie Poster
20 posts since Feb 2010
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: