Solved

New to Web Services

Posted on 2009-04-02
3
175 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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