Solved

New to Web Services

Posted on 2009-04-02
3
173 Views
Last Modified: 2012-05-06
I need help creating and consuming Web Services internally. These are steps I did.  

1.

created a function to fill dataset  on webapp1 (for web services)


   <WebMethod()> _
    Public Function MyDataset() As DataSet

        Dim constr As String = WebConfigurationManager.ConnectionStrings("myConnectionString").ToString
        Dim con As New SqlConnection(constr)
        Dim ad As New SqlDataAdapter("select *from mytable", con)
        Dim ds As New DataSet

        ad.Fill(ds)

        Return (ds)



    End Function

2. created a proxy class  on my webapp2

   - added a Web Reference then

     on aspx page  


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim xyz As New Test

        Me.GridView1.DataSource = xyz.MyDataset     <<<<<<<< error The request failed with HTTP status 401: Unauthorized. ???
        Me.GridView1.DataBind()


    End Sub

these are internal web application on my server.
0
Comment
Question by:VBdotnet2005
3 Comments
 
LVL 6

Accepted Solution

by:
Ramone_Hamilton earned 250 total points
ID: 24055814
You need to make sure that you set the credentials for your web service.  I'm not exactly sure how to do it in vb, but in C# it would be:

xyz.Credentials = new NetworkCredential("username","password");
0
 
LVL 4

Expert Comment

by:y0usuf
ID: 24055825
Add this in the web.config
<identity impersonate="true"></identity>
0
 
LVL 9

Assisted Solution

by:VikramMullick
VikramMullick earned 250 total points
ID: 24056512
you have to add Default credentials
Dim myProxy As localhost.webapp1 = New localhost.webapp1 ()
myProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
http://support.microsoft.com/kb/813834
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now