.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

Not passing service certificate to AsymmetricSecurityBindingElement

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :WCF


I need to consume a SOAP web service created in Java from a WCF client. The service I have to consume has the following constraints:

  • needs transport level security by communicating over HTTPS 
  • needs signatures on the body (soap:body element) and a custom header of each request. The signature is done using a client certificate and complies with http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0.pdf. The signature is required only on requests. Service responses are not signed.

It does not seem very complicated, but it proved rather difficult to achieve. My first attempt was to create a custom binding in the configuration file with CertificateOverTransport authentication. This had two major problems: it generated a timestamp header and included it in the signature (removing it would would throw an exception), it never included my required items (body and custom header) in the signature.

So I came to a second approach which consisted in creating a custom binding in code:

class MyBinding : Binding
public override BindingElementCollection CreateBindingElements()
  var elements =  

View Complete Post

More Related Resource Links

Problem with passing an Image as binary through web service



I have a web service that is accessed by a windows forms application and receives updates like facility name, address, image etc. Everything works fine except the image data is not being passed to the windows app. I am saving the images in database on both sides, so when I pull it from the server I use the following code

if (!reader.IsDBNull(floorPlanOrdinal))

facility.FloorPlan = (byte[])reader["FloorPlan"];

I can see the facility.FloorPlan Dimentions as 103840 when I debug this method which means that the data is pulled from the database fine.

On the forms side though the dimentions become 0, all other values pass fine except this. Here is the facility property in the web service on server side.

using System;

using System

Reading Certificate information in Windows Service

Hi, I have created windows service application, While starting the service i try to get the user certificate information using follwoing code. It is return nothing. but when i try to call the same set of code using windows application it returns the certificate. Can you provide any suggestion on why Windows service call not returning the certificate information. How we can get the certificate information in windows service application.     Dim matchedCertificate As X509Certificate2 = Nothing     Dim store As New X509Store(searchConfig.StoreName, searchConfig.StoreLocationEnumValue) store.Open(   OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)     Dim matchedCertificates As X509Certificate2Collection = CType(store.Certificates, X509Certificate2Collection)     Dim findValue As Object     ' Apply all search criterias     For Each searchCriteria As SearchCriteria In searchConfig.SearchCriteria     ' Resolve tokens in findValue findValue = ResolveTokens(searchCriteria.FindValue) matchedCertificates =   DirectCast(matchedCertificates.Find(searchCriteria.FindTypeEnumValue, findValue, False), X509Certificate2Collection)       Trace.WriteLine(String.Format("Found {0} certs with search criteria {1}={2}", matchedCertificates.Count, s

Passing return value from a Web Service to a label in a Form View

I am using JavaScript to call a web service. The JS is correctly receiving and passing the web service information. At the moment, the web service returns a country name as a string to a JavaScript alert pop up box as follows:ret = CountryRegionsWebService.GetTranslatedCountryShortName(ddl1_value, ddl2_value, OnComplete, OnTimeOut, OnError);function OnComplete(args) { alert(args); } I want to change this so that web service returns the country name to a label inside an insert item template of a form view. Is there a way to pass in the label variable to the OnComplete function signature and still account for the variable args?, such as: Server Side Declaration of JavaScript ddl2.Attributes.Add("onChange", "JavaScript:OnComplete('" + lab5.ClientID + "', '" + "args" + "');"); Client Side JavaScript function OnComplete(lab5_id, args) { var lab5 = document.getElementById(lab5_id); lab5.innerHTML = args; }  

WCF Service Unable to Access Personal Certificate Store Unless Service Account is Logged In

I created a WCF service that has a method which makes a call to a SOAP web service over the internet. In order to make a call to the SOAP web service, it requires that an X.509 certificate be sent with the HttpWebRequest. The X.509 certificates are loaded in the Personal and Trusted Certificate store of the account which the service is running under. When the service account is logged into the server, everything works just fine. However, when the service account is not physically logged onto the server, it has problems loading up the X.509 certificate and fails authentication when trying to make the HttpWebRequest. I am new to WCF services so I don't even know where to start looking. Can anyone please help? Thanks in advance.

Passing parameter into Web Service

Hi, I'm creating a web service using C#, and wondering if it is possible to capture the parameter passed in from the URL?e.g. http://www.abc.com/webservice/service.asmx?para1=one&para2=twoIs there a function or something that can obtain the parameters like the normal Request.QueryString? Thanks in advance! Rgds

Passing Parameters to Web Service Method using XML DataSource

I would like to know how to pass parameter values to a web service that I am using as a data source.  I am using the Data Source Type XML.  I have been able to retrieve data back from the web service method that does not require parameters.  But I need to be able to use a web service that requires parameter values.  How do you use the XML data source type with parameters?  I have use information from the article  http://www.codeproject.com/KB/reporting-services/SSRS2005XML.aspx. thanks, Lloyd

Passing GetObjectContext from WCF service to COM

Hi, I am trying reuse COM component in my existing application(ASP,COM).Com is using GetObjectContext and the stored session information to create the Objects inside the COM. How can set the GetObjectContext in WCF application. tried below code  in WCF but ctx is null Dim ctx As COMSVCSLib.ObjectContext Dim objAppServer As New COMSVCSLib.AppServer ctx = objAppServer.GetObjectContext()     Thanks in advance  

syntax problem passing parameter into Indexing Service Query

Hi everyone, I have the following query which works fine: select OriginalFileName from Document_Entries where EntryType like 'File%' and substring(entry,charindex('file_',entry),LEN(entry)) in (  SELECT filename FROM OPENQUERY(MySearchCat, 'SELECT Directory, FileName FROM SCOPE() WHERE    CONTAINS('' "green" '') ') )  It finds all documents in the document system which contain the word "green" using the index catalog.  My problem is that i need to include this query in a larger stored procedure which accepts a parameter for key words amongst others. I can't work out the syntax to get the @keywords parameter into query. The closest I've come is the following which runs but comes back with "incorrect syntax near keyword 'green'".  The @keywords parameter will contain any key words the user enters.   declare @keywords nvarchar(500) set @keywords='green'   Declare @query nvarchar(max) set @query = ' select OriginalFileName from Document_Entries where EntryType like ''File%'' and substring(entry,charindex(''file_'',entry),LEN(entry)) in (  SELECT filename FROM OPENQUERY(MySearchCat, ''SELECT Directory, FileName FROM SCOPE() WHERE    CONTAINS(''' + @keywords + ''') '')     )  )' exec(@query)   Any ideas? thanks Gus

WCF Service using SSL and Certificate Authentication.

Hi All,     I have a WCF service and want to use Transport Security and Certificate for Client Authentication.   When I am tryting to connect to service , I am getting the following error:   The SSL settings for the service 'None' does not match those of the IIS 'Ssl, SslNegotiateCert, SslRequireCert'.     I have configured the IIS to use SSL. Given below is the  configuration section for WCF service at server end:   <system.serviceModel> <services> <service name="HelloWorld.Service1" behaviorConfiguration="ServiceBehavior" > <!-- Service Endpoints --> <endpoint address="https://localhost/SecureHelloWorld/Service.svc/ws" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="HelloWorld.IService1"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address=https://localhost/SecureHelloWorld/Service.svc/mex binding="mexHttpsBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceCredentials> <serviceCertificate findValue="XXXXXXXXXXXXXX" x509FindType="FindByThumbprint" storeLocation="LocalMachine" storeName="My" /> <

Passing List to WCF Service

Hi, All, I'm not sure this has been covered before.  I did search, but not sure that any of those responses apply: I'm relatively new to WCF. I have the following classes:  PostAddress, EmailAddress, PhoneNumber, ContactInformation and, Person.  The ContactInformation contains each a List<PostAddress>, List<EmailAddress>, List<PhoneNumber> property.  The Person class has a ContactInformation property. When I pass my Person object to my WCF service, my ContactInformation Lists values are null.  For example: I create an address with: street, city, state, zip, country and add it to my List<PostAddress> I add the list to the Person's ContactInformation's List<PostAddress> Property I pass it to the WCF Service.  At that time, I have this: Person.ContactInformation.Addresses.Count = [the number of addresses in the list] Person.ContactInformation.Addresses[index].property = null My service inferface looks like this (I haven't fully sketched it all out yet): [   ServiceContract]     public interface IMyService { [   OperationContract]     bool FoundDuplicate( Person p ); [   OperationContract]     void SubmitNewMembership( Person p, Membership m ); } I'm using Visual Studio Ultimate 2010/.NET 4 on Windows 7 Professional Edition if that

passing messageContract object to a WCF Service method using Soap - not as a method parameter

i want a web application to create a service reference to my WCF service, insert information to the header of the soap call and call my WCF method. my WCF supports soap operations (also there is an endpoint in the config). i read about MessageContract attribute and declared one in the interface file: [ServiceContract] public interface IBasicService { [OperationContract] [WebGet(UriTemplate = "GetData?value={value}")] // Add support for HTTP GET Requests string GetData(int value); } [MessageContract] public class BasicServiceHeader { [MessageHeader] public string myString; } the implementation of the contract : public class BasicService : IBasicService { public string GetData(int value) { return string.Format("You entered: {0}", value); } } i don't want the BasicServiceHeader to be passed as a parameter of GetData function , i want to keep the function signature as it is (without a BasicServiceHeader parameter) and to extract the BasicServiceHeader inside the function, (just like using soapHeader) can i do that ?

passing XMLDocument object as input to WCF service



i have to write a WCF service which accepts XMLDocument object as input.

In my contract, I have defined a function like this:

bool validate(XmlDocument doc);

In my service, the function is implemented llke this:

public bool validate(XMLDocument doc)


code to validate the doc against an XSD file

From my test project i am passing an XML document.

But it says service cannot be found.

Instead if i define XMLDocument doc inside function like this:

public bool validate()


XMLDocument doc= path of document

code to validate the doc against an XSD file

and contract like this:

bool validate();

it works fine.

It validates the XML against an XSD and returns true or false.

Please help.

WCF service JSON endpoint with certificate



I just spend some day trying to create a WCF service that expose a JSON service authentified with a certificate. I've try some example found on the web but didn't succeed. I need to use the JSON connection with a Java client. I use WCF because in the further client they will be windows clients too.

I presume that I've made some mistakes in my configuration file. Does someone has already make this kind of endpoint to communicate with a java client with succes ? I'm pretty sure it's possible.

Thx for any pointers

Passing business objects as parameters to web service

First I will explain our architecture

All of our Business Class are put into a Project Business Classes and they are passed around different layers to get the job done

Business Layer
   --- Depending on  a configuration calls either a web service or Data Access to get its data.

Business Layer


Business Layer
Web Service
Data Access

Sample Code:

    Business Classes

    public class Customer
        private string _name;
        public string Name
            get { return _name; }
            set { _name = value; }

   Data Access
     public void Add(Customer customer)

Receive Client Certificate in Web Service


I'm trying to receive a Client Certificate in a Web Service and having some problems.


Dim cert As X509Certificate = X509Certificate.CreateFromCertFile("C:\cert.cer")
Dim hw As String = _ws.HelloWorld

The certificate seems to be correclty loading and added to the client.

The client connects to the server with HTTPS.


 <WebMethod()> _
    Public Function HelloWorld() As String
        Dim cert As HttpClientCertificate = Me.Context.Request.ClientCertificate
        Return "Hello World"
    End Function

cert.IsPresent is false and all certificate fields are empty.

IIS is configured to Accept Client Certificates.

Reproduced in two environments:

- Windows 7 x64, IIS 7, VS 2008, .NET 3.5

- XP x86, IIS 5, VS 2008, .NET 3.5

Always in the Web Service the Client Certificate is not proesent. I haven't been able to find any other configuration I should do. Can anyone help?



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?


c# .NET 3.5 Web Service with Client Certificate



I'm creating a Web application to consume a third party Web service. The third party has provided me a Security Certificate and I can use it to see their WSDL in Browser successfully.

I've created a Unit Test to consume the web service with the client certificate and it works fine.

I've also create a Console application to consume the web service, and again it works fine.

The problem is, I created a Web application (ASP .NET in IIS) to consume the web service, and it fails. The party said I didn't send the Client Certificate in the Web Service call. But the code I use is the same as the one running in the Unit Test and Console application.

Background: The Web Application has impersonate="true" and we are using Integrated Windows Authentication. Also we have a Web Proxy in our company to go out to internet.

Below is the code I'm using. I believe the code is fine as it works in some cases except in ASP .NET (IIS). 


this.BuySideService = new FXBuySideServiceV1();

// preserve cookies for auth info (SMSESSION)
this.BuySideService.CookieContainer = new System.Net.CookieContainer();

// basic authentication
this.BuySideService.Credentials = new System.

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