query in adding web service to web application

srivalli

Well-known member
Joined
May 4, 2005
Messages
189
Programming Experience
Beginner
hii all

since two days i am trying a small program in web services
what i did is i wrote a small web service for adding of two numbers
when i am running that web service it is working well an fine

now i want to add that web service to my web forms

so what i did after executing web services ,i opened new application say web application
in that i am trying to add "add web reference"

after that one screen is opened
in that i entered the web service path and when i am clicking "Add Reference"
then only "localhost is added"
generally .vsdisco .meb and other file must be included .
but it is not
only local host is added
so where is the mistake i am doing
i am trying this since two days and breaking my head
if any one has any idea abt my query then plss let me now
thanks
 
no need to break your head. you are doing everything allright.


localhost is added to your solution explorer window. that means all is ok. now you need to use the imports statement to import the web service class that you have used into your windows form application. then you instantiate the class and ur web method will be accessible. this process is called the proxy class instantiation.
 
problem in web application

thank u so much for ur response
after adding web reference to my web application,
i have created instance of that web service
but while running that application the following error is displayed

" failed with HTTP status 401:Access Denied"
now what to do
any suggestions
thanks



nakracreative said:
no need to break your head. you are doing everything allright.


localhost is added to your solution explorer window. that means all is ok. now you need to use the imports statement to import the web service class that you have used into your windows form application. then you instantiate the class and ur web method will be accessible. this process is called the proxy class instantiation.
 
in case of windows form applicatinos, when you use web services, then u must have the internet connection open else it will show you the error as was displayed by you.


web services are inherited from

system.web.webservices.webservice
 
even though i tried in web applications then the same error is displayed
same error in windows as well as web applications
so where is the error
do i need to give any permissions exclusively or problem with the server
thanks

nakracreative said:
in case of windows form applicatinos, when you use web services, then u must have the internet connection open else it will show you the error as was displayed by you.


web services are inherited from

system.web.webservices.webservice
 
its unable to locate the file of your web service so its showuing u the error of 401. this might be the case. re perform all ur steps once again and make sure that when u are adding web reference all ur steps are correct.
 
got the solution for web services

the procedure i am following for web services is correct

but the error it ias showing is "Access Denied"

so what to do is
just go to IIS

in that select the web service
right click the service
and in directory
just click EDIT
in that select Anonymous
click ok
and then click apply
then that web service is being added in web applications and windows applications

or else
instead of doing all that

just create the web service
and open new web/windows application

and in that
create one instance of that webservice
in that use "Credentials" property
then no need for enabling directory settings

thks

nakracreative said:
its unable to locate the file of your web service so its showuing u the error of 401. this might be the case. re perform all ur steps once again and make sure that when u are adding web reference all ur steps are correct.
 
hi,

In you Windows Application Add 2 things

When you create the Localhost object:-
suppose

VB.NET:
[size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] t [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] localhost.StringArray ' Webservice name 

t.PreAuthenticate = [/size][size=2][color=#0000ff]True

[/color][/size][size=2]t.Credentials = System.Net.CredentialCache.DefaultCredentials
 
[CODE]
 
This would work out 
Thanks 
        Jay
   
[/size]
 
i already mentioned that i did the same thing by adding "Credentials" property

thanks

programmerskills said:
hi,

In you Windows Application Add 2 things

When you create the Localhost object:-
suppose

VB.NET:
[size=2][color=#0000ff]Dim[/color][/size][size=2] t [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]New[/color][/size][size=2] localhost.StringArray ' Webservice name 
 
t.PreAuthenticate = [/size][size=2][color=#0000ff]True
 
[/color][/size][size=2]t.Credentials = System.Net.CredentialCache.DefaultCredentials
 
[CODE]
 
This would work out 
Thanks 
Jay
 
[/size][/QUOTE]
 
Back
Top