Cannot get a property value sent by the user on my Web Service

 Dear all,

 I developed a web service whose methods had to be the same as in our partners web service. The web service has a property "Credentials" of type NetworkCredentials :

    private NetworkCredential _Credentials;               
    public NetworkCredential Credentials
    {
      get { return _Credentials; }
      set { _Credentials = value; }
    }

 
For testing a partner's web service I instantiate his ws and I pass the credentials throu the property:  

WebService wpSynch = new WebService ();        
wpSynch.Credentials = new NetworkCredential(UserName, Password);

And everything works fine. Then I created a client application to invoke the property of my web service, passing the credentials in the same way. But once insede the called web method the Credentials property has "null" value. Since I cannot introduce further web methods, but I must use this property, could anyone suggest me how could I get the values sent by the users?

 Thank you in advance.

0
francesco_81
1/22/2009 2:56:24 PM
asp.net.xml-web-services 7071 articles. 0 followers. Follow

9 Replies
679 Views

Similar Articles

[PageSpeed] 45

The web service has that property? What do you mean? Web services cannot expose properties.


John Saunders | MVP – Connected System Developer
0
johnwsaunders3
1/22/2009 7:52:44 PM
When you create an instance of a web service, you can access its properties via the web service object can't you? Is this what is meant?
0
Tryst
1/22/2009 9:43:23 PM

What the client creates an instance of is a proxy class for the web service. That class will have methods for each of the WebMethods of the service, but will not have any of the properties of the web service class. The properties you see on the client are properties of the proxy object itself. See Ways to Customize your ASMX Client Proxy for some of the more useful properties.


John Saunders | MVP – Connected System Developer
0
johnwsaunders3
1/22/2009 9:55:36 PM

So looking at the link you posted, there is a 'Credentials' property on the proxy class, so is this what Francesco is referring to?

0
Tryst
1/22/2009 10:39:28 PM

johnwsaunders3:

What the client creates an instance of is a proxy class for the web service. That class will have methods for each of the WebMethods of the service, but will not have any of the properties of the web service class. The properties you see on the client are properties of the proxy object itself.

 

 

When I create a new instance of the Web Service I can then see the Credentials property thanks to VS intellisense. But now after what you have written it become clear to me why I did not get the values.

I already read some articles on how override the getWebRequest. However this method should be inserted in the client proxy contacting the web service. But my problem is that I cannot modify the client proxy accessing my Web Service since it will reside on our partners' side. My goal is to receive the credentials sent by partners side, hence I guess I should do something on the server side, shouldn't I?

When I send my credentials, before invoking a partner's web method, I simply use the instance of the created web service:  

wsInstance.Credentials = new NetworkCredential(UserName, Password);
without doing anything else.  Therefore my question is to get these data on the server and not how to send them (from client side), since partners will deal with that.
Thanks to all of you for your help  and patience.
Regards,
Francesco 

 

0
francesco_81
1/23/2009 8:17:59 AM

 After some further research over internet I understood that Credentials property is as sort of common property of WS and not necesserely implemented on the server.

Therefore I simply add the credentials on the client side usign a NetworkCredentials instance and I associate it to the web service instance.

Now I deleted the credentials property on my web service side, but still my doubt stands. That it is: should I then get these values within my web service or rather should I have to validate the user at IIS level?

Thanks again

0
francesco_81
1/23/2009 12:00:58 PM

First of all, if you can get IIS to do some work for you, then that sounds like a good thing. It's one less thing you need to do.

Secondly, you should read up on authentication in ASP.NET. It's possible that all you'll need to do is configure it, and use the Request.User property.


John Saunders | MVP – Connected System Developer
0
johnwsaunders3
1/24/2009 8:20:37 PM

johnwsaunders3:
First of all, if you can get IIS to do some work for you, then that sounds like a good thing. It's one less thing you need to do.
 

I perfectly agree Smile

Reading on the Net I have seen there are several ways to authenticate user accesses to a web service. In my scenario, where I cannot introduce login form or edit web methods signatures, windows authentications seems fit at best.

I read several documents about the topic but still I could not solve the problem. I disabled the anonymous access for my web service and I have enabled windows authentication.

To test it I pass user credentials to the proxy instance as:

webService.Credentials = new networkCredentials("usrName", "pwd");

 But when I try to access the web method I always get a 401 error (unauthorized request).

Could you tell me whether I forget any step? Thank you very much

0
francesco_81
1/26/2009 2:41:17 PM

I recommend that you use DefaultNetworkCredentials, not create one by hand.


John Saunders | MVP – Connected System Developer
0
johnwsaunders3
1/26/2009 6:09:26 PM
Reply:

Similar Artilces:

xml web service --uploading the file to the xml web service
how can we upload the file in the xml web service 1.i mean what will be the return value in the proxy class 2.and how am i going to send the file to the xml web service----regards Bipul Kumar Here are some links to articles that helped us get this done: http://msdn.microsoft.com/webservices http://www.microsoft.com/downloads/details.aspx?familyid=06255a94-2635-4d29-a90c-28b282993a41&displaylang=en https://www.sys-con.com/dotnet/article.cfm?id=458 Hope this helps....

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="http://www.dynix.com/schema/book">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

.NET web services Vs Java Web Services
Hello, does anyone know of a book or good source of information that compares .NET and Java Web Services? (I would like soemthing neutral if possible). I am thinking of approaching this subject for my dissertation? Many Thanks Rob Hi Rob, Last year I had to give a powepoint presentation on Web Services. I noticed some good books at barnes and noble that discussed the subject. These books were specific to Java and discussed Web Services in a very clear fashion. They gave some elementary examples that were easy to understand. I have not yet had the pleasure of creatin .NET Web Servi...

Get Users Properties with a Web Service ?
Hello, Does anyone know how I could get some Exchange users properties like total number of items, mailbox size ? What I'm trying to do is display these infos on a webpage. I looked for such a method under the Provisioning and Exchange Web Services but found nothing ... --------teebo...

what are web services and what are the advantages of web services?
 Hello  i am new to this .net stuff and i was ask on the job interview what a web services is?and if i did not know given that i had a project ( as a project manager,  or a web developer)   what  is it? how do i start a >NET project on it? what are the main advantages is?  HOW DO I START THIS IN THE INTERVIEW>  and what basic books do i buy?   Hi There, There plenty of source on the net about webservice Definiton: http://en.wikipedia.org/wiki/Web_service http://www.codeproject.com/Purgatory/Defining_Web_Services.asp...

Is web services a part of web Service?
  I have a question: Is web services a part of web server?? And when the client calls web service, it means that client calls web server?? Or is it a different entity in itself which communicates separately both with client and server and acts as middleware application.. I am very confused.. Can someone explain me the architecture...??? Thanks..Dont forget to click "Mark as Answer" on the post that helped you.This credits the member,earns you a point & marks your thread as Resolved so that new users will know where to search for their queries. When you build and dep...

Calling a Web Service from a Web Service
Hello,I was looking for some feedback on calling a web service from within a web service. I've heard that it's not good practice (or not possible). I have a scenario where I think it might make some sense.Within our infrastructure, we've created a web service that handles incoming updates on the statuses of all processes. This has proven to be a good thing since it allows applications to communicate across server to make status updates. It's also used by third party developers and applications to communicate with our infrastructure.Along these lines ... we are planning to create a new compon...

Web Site Project: How to configure web service URL in web.config (web service defined in a referenced DLL)
I have a web site that references a business logic DLL project. In the business logic project, there is a web service defined in its app.config file something like this: <applicationSettings>  <MyNamespace.BLL.Properties.Settings>    <setting name="MyNamespace_BLL_MyServer_ServiceName" serializeAs="String">    <value>http://blah.blah.blah.asmx</value>  </setting>  </MyNamespace.BLL.Properties.Settings></applicationSettings> When the web site is published, the web ...

Best Practice for .Net Web Service access to a Web Service on a Test and Production Servers
Hello All, What is the best way to control a .Net web service to be able to access a remote server for testing and then point to another remote server to access the web service in production? Do I need to generate and maintain 2 different proxy objects? TIA, Bob Bob // first create the proxy if not isvalid( i_service) then i_service = create fundtraderproxy_TradeServicesClient_BasicHttpBinding_ITradeServices end if ///You'll see code something like this in the constructor of your proxy //dynamically set the endpoint url with the user supplied value - //r...

create valid xml to send to web service based on the schema provided by web service
Problem: I have a web page which is being populated from a dataset containing multiple tables.  I now need to call a web service and send the majority of this data to be incorporate into a mainframe system.  I have been supplied with the schema that the web service will be using to validate the data.  I am new to web services and I am not sure how to take my existing dataset and transform it into an xml document that matches the schema I was provided with. There is a main schema with an element which is a custom complex type.  This custom type consists of an element whi...

New to web services, why does PB10 web service proxy wizard say there are no services?
here... http://webservices.amazon.com/AWSECommerceService/205-10-05/AWSECommerceService.wsdl oops typo... still doesn't show any services though... http://webservices.amazon.com/AWSECommerceService/2005-10-05/AWSECommerceService.wsdl "Chance" <chance@booklog.com> wrote in message news:43b44cb3$1@forums-1-dub... > here... > > http://webservices.amazon.com/AWSECommerceService/205-10-05/AWSECommerceService.wsdl > Upgraded to 10.2x and now seems to be working...at least it created the proxy. "Chance" <chance@booklog.co...

What action by a web service requires an app to update their web reference to a Web Service
I create a web reference to a web service in my aspx web application which returns an XML object. If the owner of the web service makes a change to their object am I required to do an update web reference? What if I dont use the information from the new object? thanks Larry You should make the change only if the contract b/w the two has changed (e.g. parameters, return values), etc.-Mathew Nolton Website=www.cybral.com Email=mnolton@cybral.com Blog=weblogs.asp.net/mnolton If the web service now returns a new element and my class reference doesn't match their new class ref...

How can I open a .Net web applicaiton from a web service page and return values
 Hi allhere is what I need from an Oracle jdeveloper form, click on a button, open a web application in .Net, let the user choose several options and calculate a Total Amount, return the total amount to the jdeveloper application,could it be done with a web service?the Oracle jdeveloper form calls a web service that opens my .Net  web applicationmy web application returns a Total Amount value, my web service returns the Total Amountthe jdeveloper form gets the Total Amountthanksjsn     jsn1:  Hi all here is what I need  from an Oracle jdeve...

Web resources about - Cannot get a property value sent by the user on my Web Service - asp.net.xml-web-services

Property - Wikipedia, the free encyclopedia
In abstraction, property is that which belongs to or with something, whether as an attribute or as a component of said thing. For the significant ...

Property - Wikipedia, the free encyclopedia
This article may require copy editing for grammar, style, cohesion, tone, or spelling . You can assist by editing it . In abstract, property ...

Chinese property firm Yuhu hires ex-deputy premier Andrew Stoner
A Chinese-based property firm that has donated hundreds of thousands of dollars to Australian political parties has added former deputy premier ...

Project Tetris hits commercial property market as federal government minimises costs
... The federal government's commitment to reducing its vacant office space across Canberra is having a direct impact on the commercial property ...

Mt Maunganui property home of the year - The Courier-Mail Search Search
A LUXURY beachside home in Mt Maunganui and a renovation in Auckland have won supreme awards at New Zealand's 25th Registered Master Builders ...

Treasurer Scott Morrison orders forced sale of $10m of property
Foreign investors who have bought established residential real estate without notification given until end of month to declare purchases.

Real estate: Couples opting for discount weddings to get a foot on property ladder
WHEN it comes to saving up for a home, life can get in the way.

Property estates on former Perth school sites popular with buyers - PerthNow Search Search
CRAIGIE, about 24km from the CBD, is the site of Perth’s latest residential school conversion. The first 22 blocks at the site of the former ...

Chinese property firm Yuhu hires ex-deputy premier Andrew Stoner
A Chinese-based property firm that has donated hundreds of thousands of dollars to Australian political parties has added former deputy premier ...

Esperance Bushfire: Reports of property losses as fires rage in south WA
Fast-moving, out-of-control bushfires threaten lives and homes in the Esperance region in southern Western Australia.

Resources last updated: 11/23/2015 8:51:05 PM