Solved

New to Web Services

Posted on 2009-04-02
3
171 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
Comment Utility
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
Comment Utility
Add this in the web.config
<identity impersonate="true"></identity>
0
 
LVL 9

Assisted Solution

by:VikramMullick
VikramMullick earned 250 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

9 Experts available now in Live!

Get 1:1 Help Now