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

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

WCF service JSON endpoint with certificate

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :.NET Framework


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

View Complete Post

More Related Resource Links

WCF Data Service to JSON example? v4


I would like to take WCF Data Service and produce JSON output to consume on various mobile apps.

Can anyone give me a how-to on the JSON part?  I.e., what is different than normal XML outut?



unable to use wcf service with json in asp.net



I have developed a wcf service for asp.net ajax client. It includes the following steps.

(1) Created WCF sevice contract with the operation "DoWork()" which will take string as input and retun string as output.

(2)Implemented the above operation contract(attributed the implementation class with aspnetcompatibility requirement as enabled).

(3)Added the webscriptenabled to endpoint in web.config file.

(4)Hosted the wcf servie. 

(5)Downloaded the javascript file from the service.(e.g.,http://localhost/service1.svc/js)


(1)Opend new asp.net webapplication.

(2)Added the downloaded .js file.

(3)Given the scripts path for ajaxscript manager as both .js file and service url.


<asp:ScriptManager ID="id1"

The service cannot be started. This service has no endpoint defined....But it has!?!

Hi Foks,I'm following this tutorial on how to create RESTful services in WCF:http://www.codemeit.com/wcf/wcf-restful-pox-json-and-soap-coexist.htmlI would like to test the created service using the WCF Default Test Client, but when I run the application (F5) the service does not start and I get this message:"The service cannot be started. This service has no endpoint defined. Please add at least one endpoint for the service in config file and try again."However I do have endpoints defined for this service..I also have two other services running in the same application, which work fine:This is the relevant portion of my app.config:<behaviors>              <serviceBehaviors>                        <behavior name="WCF_Lib_Default.Service1Behavior">                   <serviceMetadata httpGetEnabled="True"/>                   <serviceDebug includeExceptionDetailInFaults="False" />             &nbs

IE 8 partially cut of my JSON data return from WCF service

Hi All, I am not so sure here is the right place to post my issue. I am using ExtJS treepanel and ajax call to wcf webservice and return JSON array. My service return array. If array count is less than 2, then IE partially cut of my JSON data return from WCF service. But FireFox is working fine with same JSON format string. Very interesting thing is that I try to debug with Fildder. so I have to put "." dot in my url "http://localhost{.}:1234/ then It is working fine.   I am testing with IE8. Here is the JSON format return from FF and FireBug. {"result":[{"href":"..\/EMP\/EmployeeSearch.aspx","iconCls":"","id":"8c362443-7bb3-427e-910c-87b391c6abf5","leaf":true,"text":"Employees"}]} Here is the corrupted JSON string retrun from IE using developer tool. {"result":[{"href":"..\/EMP\/E" [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "GetSiteMap", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] [return: MessageParameter(Name = "result")] List<TreeView> GetSiteMap(string node);

Can I write a wcf endpoint to communicate with JSON from Jquery on page?

Hi Guys,I need to be able to expose information to a page, and I need to write the information in xml on my webserver which will be dynamically created from the database. I need to use json to pass the data from the screen back to the server two way communication xms back and forth. Is it actually any good using a wcf endpoint to serve the json back to the page and use query with wcf? Is this possible?Or is it easier to use standard pages .aspx and just do a call to a url and get the json with jquery....We will probably want to send this information to other locations at some point in the future too....Cheers,Pete

How to set and map a Method in the Service file with endpoint elements and binding elements

Hi all, I have created a service file like OSService.svc in that i have two methods like one is FileUpload and FileDownload for e.g :- [WebInvoke(UriTemplate = "/fileupload/{fileName}" , Method = "POST" )]         [OperationContract]         void FileUpload(string fileName, Stream fileContents); same as Filedownload also. People you may know these methods are inside the interface of service file what you are using i'e i have created a interface as IOSService.cs. So, what i need now is i want to write separate endpoint for FileUpload and Filedownload.Because i want to set separate value for receiveTimeout  and openTimeout for the Fileupload and FileDownload process in binding section in the web.config file itself. The below code was i'm using right now but still i'm not able to the set separate value of endpoint elements in the bindings. EndPoint Section:- <endpoint name = "endPoint1"  address  = "localhost:8000/OSService.svc/" bindingConfiguration = "TransactionalTCP"   binding  = "netTcpBinding"          contract = "IOSService"/> Binding Section:-  <binding name = "TransactionalTCP"  transactionFlow = "true"   /&

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

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.

Calling one endpoint from another endpoint in the same service

Hi, I have a WCF service host Im hosting in IIS that defines a few services and one of those services has a number of endpoints. The endpoints that belong to the same service are there to let me specify different contracts and they all use the same binding and behaviour. For the most part it works fine until a specific situation occurs: The service gets stuck when one of the endpoints tries to make a call to another endpoint in the same service. Consider the following example: <service behaviorConfiguration="GeneralServiceBehavior" name="Base"> <endpoint address="/Addresses" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig" contract="CommonObjects.IAddresss" /> <endpoint address="/Attachments" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig" contract="CommonObjects.IAttachments" /> </service> In the example above if a call is made from IAttachments implementor back to this service to access the IAddress endpoint I get stuck in what seems to be a deadlock until I get a timeout on the calling thread and then I see the call come through to the IAddress endpoint, but at that point its already too late as the channel is closed. I have looked at the InstanceContext and ConcurrencyMode. This particular servic

Incorrect hostname in EndPoint location in WSDL for a service with multiple bindings and with multip

We have a WCF web service that is exposed through multiple bindings.  The site is  accessed through multiple IP Addresses/Hostnames (internet/intranet).  Some of the bindings use http transport while others use https transport. The web application is configured to use .NET 4.0 with multipleSiteBindingsEnabled="true" so that we shouldn't have problems with multiple ip addresses/hostnames. What we see is that when the WSDL is accessed using a http based URL (external), the hostnames in the endpoint addresses for http transport based bindings in WSDL are correct (ie, they use the hostname header from the request) while the hostnames in the endpoint addresses for https transport based bindings in the WSDL are incorrect (ie, they do not use the hostname header in the request - they seem to use the hostname from the first available binding in IIS for that scheme and end up with the local machine names/ip addresses in the URL).   We could work around by setting the external hostname/ip in the first binding in IIS for the respective scheme, but then WSDLs accessed from intranet clients would have wrong URLS now. This happens the other way around as well, ie, when the WSDL is accessed using https, the https based addresses are fine, but http addresses in the WSDL are not correct. It looks like hostname header is used only for WSDL endpoint addre

JSON and 2.0 Web Service

Just ramping up on JSON and JQuery and returning data to a ASP.NET web page from a web service using Ajax.  The JQuery part is pretty straight-forward.  However, when trying to return JSON formatted data instead of XML from a 2.0 web service, I'm stuck.  The web service does have the System.Web.Script.Services.ScriptService attribute, so I can hit it via JavaScript; however, the web service always...always...returns data in XML format, no matter if I explicitly say I want JSON as the datatype in my JQuery code.  So I don't know if this is an issue with the web service or the JQuery code.  I posted this here, but realize that the category could be incorrect depending on where the issue is.  Is there no way to return JSON data from a 2.0 web service?  It's a production web service, so I can't change the code unfortunately.    

How to use return JSON object from web service as a declared Type?

Hi, I just hit the following issue: I am calling a web service that returns a serialized JSON object let's say: __type, FirstName, LastName (.net object Person with properties FirstName and LastName). __type's value is Test.Person I have created a JS object using Type.registerNameSpace/registerClass called Demo.Person and it is registered on the page using the ScriptManager. Everything is working fine; I am able to get data from the server on the call back. Is it possible to make the returned object from the web service be an instance of the declared JavaScript Demo.Person class? The idea would be to call a method like result.getFullName() on the client side without having to copy all the properties. This is just a simple scenario for more complex objects.   Thanks,   Teo

WCF : How to prevent an endpoint from being published in the service WSDL?

Suppose I have a WCF service which has 2 endpoints A and B. I want to enable mex/wsdl on this service but my requirement is that B should not be published in the WSDL. So to say B is only for internal purpose and clients should never be aware of it. Is there a way (most probably somehow using IWsdlExporterExtension), to remove this endpoint B from being published in the metadata?

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" /> <

Web Service and JSON input data

Hy, I'm try to build a web service who can get in input a JSON string. My web method is: [WebMethod(Description = "Edit Entity")][System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]public string ManageEntity(string _DataIn){ // System.Diagnostics.Debug.WriteLine(_DataIn);            return "{\"Result\":\"OK\"}";} When I try posting some data to the webservice I get the error "No parameterless constructor defined for type of 'System.String'". Why the system try to deserialize my JSON string? Is possible to simple retrieve the string? Thanks Lorenzo SonciniLorenzo Soncini

Make my WCF service return json

Iam trying to make my wcf serivce method to return JASON-object, but it dosen't work, when I open in a webbrowser it shows xml. How can I make this method to return json.I have inserted [WebGet(ResponseFormat = WebMessageFormat.Json)],,,, but it didn't help[WebGet(ResponseFormat = WebMessageFormat.Json)] protected override IEnumerable<KeyValuePair<string, SampleItem>> OnGetItems() { // TODO: Change the sample implementation here if (items.Count == 0) { items.Add("A", new SampleItem() { Value = "A" }); items.Add("B", new SampleItem() { Value = "B" }); items.Add("C", new SampleItem() { Value = "C" }); } return this.items; }[WebGet(ResponseFormat = WebMessageFormat.Json)]         protected override IEnumerable<KeyValuePair<string, SampleItem>> OnGetItems()         {             // TODO: Change the sample implementation here             if (items.Count == 0)             {                 items.Add("A", new SampleItem() { Value = "A" });  &nb

Can't Add Service Reference in VS 2010 to a net.tcp endpoint

I've got a service running (well, it doesn't crash), but when I try to add a Service Reference to it, I keep getting Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:55555/mex'. Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:55555/mex'. If the service is defined in the current solution, try building the solution and adding the service reference again. The pertinent parts of my config file are:   <netTcpBinding> <binding name="ReliableDuplexBinding" closeTimeout="00:00:10" openTimeout="00:00:10" receiveTimeout="00:00:30" sendTimeout="00:00:15" maxBufferPoolSize="1048576" maxBufferSize="262144" maxReceivedMessageSize="262144"> <readerQuotas maxDepth="33" maxStringContentLength="100000" maxArrayLength="131072" maxBytesPerRead="262144" maxNameTableCharCount="54000" /> <reliableSession inactivityTimeout="05:00:00" enabled="true" /> <security mode="None"> <transport> <extendedProtectionPolicy policyEnforcement="Never" /> </transport> </security> </binding> </netTcpBinding> <behaviors> <serviceBehaviors> <behavior nam
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