.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Looking for a simple Service and Console Client REST sample implementing BASIC authentication

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net

Does anyone know of a C# code sample demonstrating WCF REST services and console test client with OperationContracts (GET and POST) implementing mutiple paramaters using BASIC authentication? Also, perhaps, using Fiddler as a test client as well? I have searched high and low for something like this, but have not had any success.

View Complete Post

More Related Resource Links

ASP.Net Client for Php REST Service

 I am writing some code in an asp application that needs to communicate with a PHP REST Service. I have 2 questions. 1.  In my data variable I have to put the POST parameters.  If I needed to put reserved characters like & or ? into the string is there an escape character I can use?  Or would encoding it work?  Or would it totally depend on how the web service works? 2.  Is the code I am using the usual way to make a POST connection to a REST service?  Or is there an easier/faster way? Below is the code I am using Dim uri As New Uri("http://help.domain.com/api/index.php?method=request.create") Dim data As String = "tNote=Testing Code&sEmail=test@test.com" If uri.Scheme = uri.UriSchemeHttp Then Dim request As HttpWebRequest = HttpWebRequest.Create(uri) request.Method = WebRequestMethods.Http.Post request.ContentLength = data.Length request.ContentType = "application/x-www-form-urlencoded" Dim writer As New StreamWriter(request.GetRequestStream) writer.Write(data) writer.Close() Dim oResponse As HttpWebResponse = request.GetResponse() Dim reader As New StreamReader(oResponse.GetResponseStream()) Dim tmp As String = reader.ReadToEnd() oResponse.Close()

Sesame: Spatial OData on Maps, Service Operations, HTTP Basic Authentication

Sesame Data Browser has just been updated to offer the following features for OData feeds: MapsImproved Service operations (FunctionImport) supportHTTP Basic Authentication supportMicrosoft Dallas support Maps Sesame now automatically displays items on a map if spatial information is available in data.This works when latitude and longitude pairs are provided.Here is for example a map of drinking fountains in Vancouver:This comes from DrinkingFountains in http://vancouverdataservice.cloudapp.net/v1/vancouver, which provides latitude/longitude for each fountain. Here is another example, without latitude/longitude this time: This is a map of the customers from the Northwind database, which are located based on their country, postal code, city, and street address. Service operations (FunctionImport) Support for service operations (aka FunctionImports) has been improved. Until now, only functions without parameters were supported. It's now possible to use service operations that take input parameters. Let's take as an example the GetProductsByRating function from http://services.odata.org/OData/OData.svc.This function is attached to Products, as you can see below: A "rating" parameter is expected in order to open the function: After clicking Open, you'll get data as usual:HTTP Basic Authentication New authentication options have been added: HTTP Basic and Dallas (more

silverlight + WCF Service + Dynamic proxy(custom binding) + basic authentication on iis

hi all, I am having an issue with how to get windows identity in silverlight project. Below is my scenario: the silverlight application need to get data from server via WCF service, i used the way that built dynamic proxy at runtime and aslo used custombinding in this case. Now my application need to deploy on iis and chosen "basic authentication" as a authentication mode. Thus i have chosen authentication mode in WCF was " <security authenticationMode="UserNameOverTransport">". At the client side where kind of project is silverlight that i need have to dynamic proxy with custombinding. My question is: In basic authentication how can i get windows identity to set to chanelfactory.Credentials: _channelFactory = new ChannelFactory<TWebService>(this._binding, new EndpointAddress(_endpointAddress));            _channelFactory.Credentials.UserName = new UserNamePasswordClientCredential();            _channelFactory.Credentials.UserName.UserName = "username";            _channelFactory.Credentials.UserName.Password = "password"; actually, i do not want to use Windows a

A Simple Sample of a TcpListener and Client


Well For the last 2 weeks I been going threw all the samples on google that I can fine. and well they just don't work in a windows form. Ir they just don't work.


The Sever

I have one TextBox and 2 buttons (Start and Stop)


The Client

I have 2 text box and 3 buttons

Textbox 1 is for messages from server

Textbox 2 is for that user to send message and a button to send

The other 2 buttons are (Connect and DisConnect)


Can any one tell me where I can get a Simple TcpListener and and TcpClient for a windows Form that is that simple.






Toppers BBS http://toppersbbs.dtdns.net C# Windows and Console applications. PHP, Mysql. HTML

Basic authentication for Web service


Hi everybody,


i call my project web service, previously there was no pre-authetication. Now i didn't work web service. My code is as follows:


 //Cache'lenecek olan güvenlik dosyasi  
         CredentialCache credentialCache = new CredentialCache();  
         //Güvenlik dosyasinin olusturulmasi  
         NetworkCredential credentials = new NetworkCredential("username", "password");  
         //Güvenlik dosyasinin cachelenmesi  
         credentialCache.Add(new Uri("url"), "Basic", credentials);  
         //Web servisin classindan türetilmis ws objesi  

            spectrawsdl sp = new spectrawsdl();
            sp.Credentials = credentialCache;
            sp.UseDefaultCredentials = false;
            mainResponseType mrp= sp.addIncident("Test", "test", "test", "test");

What should I do?



WCF Client implementing a WCF Service that has [DataMember(IsRequired = false, EmitDefaultValue = fa


Let's say we have a WCF service that implements a service that returns a response defined in this data contract;

public class Response
   [DataMember(IsRequired = false, EmitDefaultValue = false)]
   public long OrderID;
   [DataMember(IsRequired = false, EmitDefaultValue = false)]
   public long ErrorID;
   <snip />

If I implement the service in a WCF client, the client's Response object creates two properties;

long OrderID;
long ErrorID;

These properties are non-nullable (since the datacontract didn't define these as nullable). Yet, since the member can be omitted, shouldn't the WCF client implement these properties as nullable?

The SOAP messages are formed according to the data contract. For example;




Hence, I would EXPECT the client to implement the properties as 'nullable'. This is not the case.

Can anybody explain why this is implemented this way?


WCF Service to WSE Client - Certificate authentication over SSL

I am trying to access a WCF service with a WSE 3.0 client over SSL using certificate authentication.  I can do it over an unsecured channel using a customBinding on the service side using the MutualCertificate authentication mode and the turnkey policy assertion mutualCertificate11Security on the client side.  This breaks when I move it to a production environment accessible only by SSL and either (1) change nothing in the server config file--connection gets refused because it is not https--or by (2) changing the server custom binding to CertificateOverTransport--client errors with this:  System.InvalidOperationException: Security requirements are not satisfied because the security header is not present in the incoming message.

My question is simply, how do I access a WCF service over SSL using certificate authentication?


How do I add a service reference when Basic Authentication has been enabled


I am trying to enable Basic Authenticaion for my WCF service, whicn requires disabling anonomous athentication and enabling basic authenticaion in IIS. Now I am unable to add the service reference, which is requiring authentication to complete and getting the following error:

Metadata contains a reference that cannot be resolved: 'https://l01billm/wcf4test/Service1.svc'.
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was ''.
The remote server returned an error: (401) Unauthorized.
If the service is defined in the current solution, try building the solution and adding the service reference again.

create proxy client with SvcUtil from service using https+cert authentication


Hi all,

I have build two web services one is wcf hosted in iis and the other one is java web service (jax-ws ri) hsted on tomcat. Both of the services uses https and certificate authentication.The certificates are valid and when I check the wsdl's from the browser I can see them without any warning.

So I want to create a wcf client for the services with svcutil. I have created the necessary config file for svcutil (svcutil.exe.config).

When I try to create the proxy files for the java service (svcutil http://JavaServiceIpAddress/service?wsdl) I receive

"metadata contains a reference that cannot be resolved .

<Fault xmlns="http://schemas.xmlsoap.org/soap/envelope/" >
   <faultcode xmlns:a="http://www.w3.org/2003/05/soap-envelope" xmlns="">a:Client</faultcode>
   <faultstring xmlns="">Cannot find dispatch method for {}</faultstring>

the request was aborted: Could not create ssl/tls secure channel"


When I execute svcutil http://WcfServiceIpAddress/service.svc the proxy and configs file are created smoothly. When I try svcutil http://WcfServiceIpAddress/service.svc?wsdl

"error: cannot obtain metadata from http://WcfServiceIpAddress/service.svc?wsdl


How do I get the userName and passWord sent by a client using http basic authentication in a wcf se


Hello Guys,

I need to get the username and password that my java clients are passing using basic http authentication.

The message my clients are sending is the following:

POST http://localhost:1715/PanelService.svc/PanelService HTTP/1.1<br/>
Accept-Encoding: gzip,deflate<br/>
Content-Type: text/xml;charset=UTF-8<br/>
SOAPAction: "http://br/com/petrobras/operational/services/PanelService/getAverageByBusinessObject"<br/>
Authorization: Basic YWJjZGVmOjEyMzQ1Ng==<br/>
User-Agent: Jakarta Commons-HttpClient/3.1<br/>
Host: localhost:1715<br/>

ASMX Web Service using Forms Authentication, how to Authenticate into it using WCF Client?


Hello All, a third party vendor is offering our company a ASMX Web Service which uses Forms Authentication and it's also secured using SSL.

Our Platform is .NET 3.51/WCF/C#. How should I Authenticate my Client into that kind of ASMX Web Service?

Can anyone point any article with sample code or an example how a Client can Authenticate into such ASMX Web Service,

Thanks in advance


How to write a simple Web service by using Visual Basic .NET or Visual Basic 2005

his article describes how to write a simple Web service, called MathService, that exposes methods for adding, subtracting, dividing, and multiplying two numbers.

Problem to obtain client IP on web service



I'm having problems to obtain the client IP on web service. Here's my scenario:

One server with Windows 2003, hosting the web service using .Net Framework 2.0, with IP and host name ServerTransaction.
Other server with Windows 2003, hosting a web application using .Net Framework 2.0, that consuming the web service on  ServerTransaction, with IP and host name ServerApplication.
Many other computers on the local network (IPs:,,, ...) acessing the web application on ServerApplication.

On the code of the web service I've tried to use HttpContext.Current.Request.UserHostAddress or HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") or HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FORR"), but always I can only get the IP of ServerApplication (

Any idea or tip?

Thanks and sorry for my bad english.

Smart Client: Building Distributed Apps with NHibernate and Rhino Service Bus, Part 2


Smart client applications are responsive and promote interactivity with the user. In this article, we continue building a smart client application using NHibernate for data access and Rhino Service Bus for reliable communication with the server.

Oren Eini

MSDN Magazine August 2010

Smart Client: Building Distributed Apps with NHibernate and Rhino Service Bus


Smart client applications are responsive and promote interactivity with the user. In this article, we start the processes of planning and building a smart client application using NHibernate for data access and Rhino Service Bus for reliable communication with the server.

Oren Eini

MSDN Magazine July 2010

Service Station: More On REST


This month's column answers frequently asked questions about implementing REST.

Jon Flanders

MSDN Magazine July 2009

Extreme ASP.NET: Client-Side Web Service Calls with AJAX Extensions


Microsoft AJAX Library and the ASP.NET 2.0 AJAX Extensions provide a number of compelling features ranging from client-side data binding, to DHTML animations and behaviors. Learn all about them here.

Fritz Onion

MSDN Magazine January 2007

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend