.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

How do I add the client certificate to a soap request?

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application

hello all,

I want to add the client certificate to the web request, but i'm unable to do it because it's not visible. here are the examples:

I have a web test project. if i add an asmx webservice to the web protect, i am able to do this


void buttonclick()
   WebService1 ws = new WebService1();
   ws.URL = ... someURL;
   ws.ClientCertificates.Add(new certificate in here); 


here's the problem,
if i add a webserivce project to the current solution (web test solution). And I reference the webservice. and when i do this:


void buttonclick()
  InstantName.Service1 ws = new InstantName.Service1();
  ws.URL ...??? Don't see it
  ws.ClientCertificates.Add( ... not here ... ) 


both web services class inherits the System.Web.Services.Protocols.SoapHttpClientProtocol

i don't get it ... anyone has experience with this, please give some input .. thank you.

View Complete Post

More Related Resource Links

Need help in reading Soap request and response on invoking WCF client assembly

Hi All,   I'm new to WCF and i'm using .Net 3.5. I have created a library from the proxy class generated through svcutil. I'm able to succesfully invoke service methods. I was wondering how to capture the request and response soap xmls so that i could render it on browser. If you have any code piece for this kind of problem please share it with me. Regards, Rahul

Seeing the SOAP request sent from a Web Service Client/Consumer

Hello, I am building a web service consumer in C# in VS2010.  Using the provided WSDL, I need to build appropriate headers and use certificates, SSL (user name & pass), & WS security.  I am getting an error from the webservice side, specifically processing the <wsse:Security> header. Is it possible for me to see the exact request I am sending to the Webservice? I'd like to see the values of the pieces of the header that get put in and such. Is it possible to have human readable serialization of what's being passed in right before the error? Thank You

Sign outgoing client request SOAP body with WSE 3.0



We currently have the code in WCF to sign the outgoing client requests' SOAP Body, however we need the same code for use with WSE 3.0.  I can't find any examples of this.  

Is it possible?  If so, does anyone have an example?

Thank you,

Fetch raw XML for SOAP request and response inside WCF client


I've got a basis WinForms test harness that's implementing a WCF client (.NET 3.5) which calls a SOAP web service.  I need to be able to write the HTTP request and response and output the two XML documents so I can load them back into WebBrowser controls on the form.

It looks like the way to accomplish this is to implement a custom IClientMessageInspector and an IEndpointBehavior, apply the behavior to the binding and then do the work of capturing the XML inside AfterReceiveReply and BeforeSendRequest (inside IClientMessageInspector implementation).

So my questions are:

1. This seems like a rather exhaustive process, is there a more straightforward approach to doing this? 

2.  If I am on the right path, does anyone have links to related articles/code samples related to this?

3. In what I have coded so far, I am held up trying to get the behaviorExtension to register properly (inside app.config), it looks as if I must register my classes that implement behavior Extenshions in the GAC in order to make use of them, is this true? 

Thanks in advance for taking time away to help a fellow developer!

SOAP: Using ATL Server to Build an Asynchronous SOAP Client in Unmanaged C++


SOAP opens up a new world of Web Services, letting you make function calls across a network or the Internet. But this flexibility creates new problems when your app needs to wait for calls to return from halfway around the world. What you need is an asynchronous SOAP client that takes advantage of threading to continue execution while waiting for calls over the wire. This article covers the basics of building such a client with ATL.

Pranish Kumar and Bogdan Crivat

MSDN Magazine April 2002

sslstream client certificate validation error

Hi,I have taken server and client program from MSDN2 for sslstream. in that code client certifiacte authetication is made false  i want to enable that and do the code i have done some modification to the code but is giving error "RemoteCertificateNotAvailable" and i think that its not getting the client certificate at server side.So please can any one help me to do client server program using sslstream in which client certificate also needs to be validated.I am attaching my modified code of MSDN2Server sideusing System;using System.Collections;using System.Net;using System.Net.Sockets;using System.Net.Security;using System.Security.Authentication;using System.Text;using System.Security.Cryptography.X509Certificates;using System.IO;namespace Examples.System.Net{    public sealed class SslTcpServer     {        static X509Certificate serverCertificate = null;        // The certificate parameter specifies the name of the file         // containing the machine certificate.        // The following method is invoked by the RemoteCertificateValidationDelegate.        public static bool ValidateClientCertificate(              object sender,              X509Certificate certificate,              X509Chain chain,              SslPolicyErrors sslPolicyErrors)        {            SslPolicyErrors errors = sslPolicyErrors;            if (errors != SslPolicyErrors.None)            {

Certificate Signing Request Tool

Hi All, Currently there is a requirement in our application for creating a SSL Certificate Signing Request (CSR) message. Is it possible to develop one on .Net Framework 3.5 Some of the websites lilke Verisign do not mention any such procedure where they say that a custom tool is available apart from OpenSSL but they basically have provided a list all the webservers where their Digital Certificates are compatible and the instructions which say how the CSR's can be generated on these web servers.  I understand that the CSR contain the Web Server's public key, organization information and a unique match for server's private key. The certificates issued by the Certifying Authority  is used for Cient/Server authentication over TCP/IP. Look forward for some replies Thanks

How to bind a WCF Http client to a specific outbound IPAddress before making the request

I want my request to go out through a specific IP Addresses. Is there a way to do that in WCF. The explanation of why I need this is a little long winded so i'd rather not get into that. Here is sample code string ipAddress = ""; IService service; ChannelFactory<IOmlService> factory = new ChannelFactory<IService>(new BasicHttpBinding(), new EndpointAddress("http://" + IPAddress + ":6996/IService")); service = factory.CreateChannel(); service.Test(); Here is an example scenario to explain exactly what i'm looking for. Let's say I have two IPs on my machine ( and Both of them can hit If i run this code now, it will hit the IP (.32) from any of my IPs (.30 or .31). How can i force it to go through a specific IP of mine (say .30). Is there any way to do that using WCF? Thanks

connect client certificate to an account in a membership database

Hello I have created a web service that authenticates with username and password, works fine.Basically this one, http://msdn.microsoft.com/en-us/library/ff649647.aspxNow I also want to connect to this web service using client certificates, works finehttp://msdn.microsoft.com/en-us/library/cc948997.aspx But I would like to when authenticated via client certificates, connect that certificate to a user in the membership database.So that I can use Roles.IsUserInRole(...) and such.I thought that, well if I implement a Custom certificate Validatorhttp://msdn.microsoft.com/en-us/library/ms733806.aspxthen I could check for example subject and map that against a created username in the membership database.But in the class X509CertificateValidatorpublic override void Validate(X509Certificate2 certificate)I don't have the same ability as when the user is authenticatedlike  void OnAuthenticateRequest(object source, EventArgs eventArgs)HttpApplication app = (HttpApplication)source;Basically how can I do this app.Context.User = new GenericPrincipal(new GenericIdentity(username, "Membership Provider"),roles);withinpublic override void Validate(X509Certificate2 certificate)and if that is not possible, can this be solved differently?Bottom line, how do I connect a client certificate to a user account in the membership database. Is there a MSDN article

sending xml inside a soap request with HttpWebRequest

Im trying to send some xml inside a soap request to a webservice using the HttpWebRequest class.  I know this isnt the best way, but my hands are tied by company policy so i have to do it this way.  My webmethod has an input parameter  "SourceXML"  so my soap request has this node<SourceXML></SourceXML>I need to insert the xml in this node but whenver I insert it and try to send it to my web method I get an error "400 bad request"Is this even possible ?  I need to insert the xml as a string literal and read it in the web methodStringBuilder sb = new StringBuilder(_soapEnv); -- soap enevlope template containing the SourceXML node sb.Insert(sb.ToString().IndexOf("</SourceXML>"), the xml I want to insert in the node); sendmessage(url, webmethod, sb.ToString()) -- send the message to the webserviceIf I put plain text in the string builderegsb.Insert(sb.ToString().IndexOf("</SourceXML>"), "this is a test");everything works ok, but as soon as i put some xml in it fails. Am I going about this in the right way ?basically my webmethod will have 2 input parameters, some xml and an object, but I just cant get it to work. Can anyone help ?

Getting client information from X.509 certificate in C# code

I have a WCF service which accepts X.509 certificate signed incoming messages. As per my understanding the client will send the message with signature encrypted using his private key and web services will decrypt the signature with client's public key. This ensures that the sender of the message is holder of the private key and that he is certified by the server trusted CA as "He is what he claims to be". It's being a highly secure application I need to give access to only certain clients regardless of whether they are trusted or not. (This is to take care of good turned bad scenario :-)) How do I achieve this? Is there any way to get the client information as subject name etc from his certificate in C# code? Is there any example of this usage? Thanks in advance,Jeet.    

Soap Extensions loading on host only, none on client

I have soap extensions enabled in my web config, but they only intercept the soap messages at the host (AfterSerialize, BeforeDeserialize).  How can I get the client (BeforeSerialize, AfterDeserialize) extensions to kick off?  I have the client and host in the same project.  My web config is as follows: <webServices>       <soapExtensionTypes>         <add type="SoapDisplayExtension.SoapDisplayExtension, SoapDisplayExtension" priority="1" group="High"/>       </soapExtensionTypes>       <protocols>         <remove name="HttpGet" />         <remove name="HttpPost" />         <remove name="Documentation" />       </protocols>     </webServices>

Work with SOAP requests via Raw request

I will handle SOAP requests via IHttpRequest. What best way to work with raw SOAP requests (mean how desearialize etc)?

C# Client App connecting to WSS3.0 with X.509 certificate

I have been unable to find much information on using smart cards and X.509 certificates when connecting to WSS 3.0.  I am able to build a Web Service Reference in VS 2010 just fine.  I get prompted for my cert, I select it, enter my pin and all is well.  But I am failing to handle it properly in my app.  I created a test method that creates the new WSS List object.  I assign System.Net.Credentials.DefaultCredentials to the Credentials. I then call GetListCollection.  I am never prompted for my cert, and I get a 500 error back from the server.  Everything works fine in IE and adding the reference so I think I missed a step, but I cannot figure out what that would be. I running the app with an account that has no relationship to the authentication domain WSS is part of, so I expected to be prompted for the cert when I tried to connect. Does anyone know how to do this, or offer up some guidance.  Thanks, LD

SharePoint - Report Server - Client Certificate authentication

Hi,I have a SharePoint site collection which requires client certificates. On the server I have configured Reporting Services in integration mode.I can call reports on other site collections which don't require client certificates but not on the site which does. On the site which requires client certificates the pages fail with the following error message:'An unexpected error occurred while connecting to the report server. Verify that the report server is available and configured for SharePoint integrated mode. --> The request failed with HTTP status 403: forbidden'The error message indicates that SharePoint doesn't call the web service with a client certificate. Does anyone know how I can configure SharePoint to use a client certificate?Any help is greatly appreciated.Adam

Signing The Body of a Web Service Request (From Client)

Hello, I attempting to consume a webservice, which has numerous security factors, one of which is SSL. I am using WS-Security and attempting to sign the body of my request.  Right now it is only currently signing the timestamp and to: (endpoint).  I've been scouring the forums, but seem to come to a dead end with threads dying off... http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/034f71cd-408e-447c-a95c-e0cf4baa5742 I'm assuming I will have to modify the reference.cs file or maybe even the WSDL, but here's some of the code I've done for the binding..is this on the right track? WSHttpBinding myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.TransportWithMessageCredential; myBinding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate; myBinding.Security.Message.NegotiateServiceCredential = false; myBinding.Security.Message.EstablishSecurityContext = false;

x509 - Client Certificate infrastructure for Asp.Net question

I dont have a lot of background with SSL and X509 configuration and support with my Asp.Net application, so I was wondering if someone can explain or point me in the right direction to MSDN or any other article or posting explaining if it's possible to do what I am looking to support in my environment.I have IIS 6.0 with SSL (Verisign cert) as well as "Require client certificates" working against a local installation of Microsoft Certificate Services, https://<domain>/certsrv, where users can request and install client certs (both xp clients for basic mode, and Vista/7 for advance mode).Here's what I am up against:I have a segment of users coming from a virtualized server environment where this environment does not store personal settings for more than 48 hours. It's not an internet cafe, but rather an actual business where their IT staff uses server images to reimage each virtual server in the farm every 48hrs. Thus losing all users data in the "Current Users" Certificate Stores.The IT staff give users a network folder share to store any personal items (docs, spreadsheets, links, etc.). The servers consist of Windows Server 2003, and will be migrating to Windows Server 2008 in the next 6-9 months.These users have rights in Internet Explorer to navigate to my certsrv site and use activex to to request and install certificates then clode and
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