|Azure Active Directory and WCF authentication|
Do I understand you correctly that you want your WCF service to use
tokens issued by Azure Active Directory as the identity:
Thread.CurrentPrincipal? The WsFederation binding speaks wstrust and
AAD doesn't. It looks like you are using a smart client, as opposed to
a browser? Is that correct?
AAD serves up identity tokens using: wsfederation and openidconnect
both passive protocols.
AAD does serv
|browser keeps downloading .svc files WCF|
If your WCF Service is in .Net Framework 4.0/4.5, then check the .Net
Framework version in Application Pool.
If it is 2.xxxxxx, change it to 4.xxxxx.
|WCF 4.0 Service crashes|
This are pure assumptions, but as far I guess by looking at your
traces and what you wrote:
You are using a net.pipe WCF host
The endpoint address of your host is net.pipe://tstwebashitv...
something, so you are not using a the net.pipe://localhost/... format
(assuming tstwebashitv is not a server name, and your net.pipe is not
The service used to work for a long time
So I assume there
|Hosting a WCF service endpoint for Azure Service Bus Relay inside an Azure WebSite|
The answer to this is pretty simple - don't use localhost or IPV6
[::1] - get the IP address from the machine its running on with the
var ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList.Where(o =>
|System.Exception must be XML serializable to be a message part type|
The better option here would be for your WCF Service to throw a SOAP
Fault in this case. This can be a general SOAP Fault or a typed fault
See here for more information regarding SOAP Faults:
Then, when dealing with SOAP faults in your orchestration, there is a
best practice to do this by setting propagate fault message like this:
|WCF returning nil value and actual value in Data Contract|
It seems that the problem was caused by the WSDL and Data Contracts
not matching the web services themselves.
Running svcutil.exe against the web services that were running and not
the WSDL files provided fixed the problem.
|Lync 2013 UCMA WCF Web Service|
You can also do a one-time presence query. From MSDN:
If a one-time presence query to a remote presentity is desired,
creating a view and tearing it down is a suboptimal solution for an
application. In addition, the application needs to wait and track
whether all presence information has been received.
An alternative is to use the
BeginPresenceQuery(IEnumerable<String>, , EventHan
|Must I add a WCF service class library in order to host a WCF Service in a Windows service?|
OK, here is what I found.
Creating a new solution with one Windows service project with a Wcf
service class and one Asp.Net folder.
Running the Windows service.
Trying to add a Service reference to the Asp.Net project.
Result: Service can't be found.
Adding a new project which contains a Wcf project to the solution.
Adding a reference to it from the Windows Service.
Trying to add a Service
|Silverlight and WCF error|
The clientaccesspolicy.xml and/or crossdomain.xml files are not
required inside your client application, and they do not belong in
your web service directory. Rather, they must be copied into the root
of your web server. Mostly, that would be the directory
C:inetpubwwwroot instead of C:inetpubwwwrootPDFService.
|Disable CustomUserNamePasswordValidator for specific operation|
I have done something like this before,
depending on how you have integrated your custom validator in the wcf
you could simply before you do the actual validation, which I guess
returns something like true or false, you could check the incoming url
or address and see if it is going to be going to your IsAlive
operation, if that is the case, you could simply do a early return
|Simple.Odata.Client Retrieve Data From WCF Dataservice|
Since you are getting InternalServerError it's most probably something
with the service implementation or setup. I suggest you first isolate
the error by running a query in the browser. Try something like
SERVER_URL/Details (I assume you have an entity set called Details)
and check the response from the server. If this doesn't work then your
problem is the server. If it works, check your Simple.Da
|ASMX WebService with string return value (or parameter) forcing message contract generation in WCF Client|
I found a solution for this. Looks like it is a result of using the
DataContractSerializer which is selected by default. There's no fix
for this in the GUI provided in Visual Studio. To configure this
manually, open the Reference.svcmap file on the client side of the
service and change <Serializer>Auto</Serializer> to
This caused the
|How to enable HTTPS in WCF service|
Your binding has this:
Which means your service is not expecting to use security of any kind.
HTTPS is transport authentication, so you need to set:
The following link includes useful information about setting up
transport security in WCF:
|WCF MaxPendingAccepts: Default value 0|
I took a look at the source code for
System.ServiceModel.Channels.HttpTransportBindingElement. The default
constructor for the class has the following line of code:
Taking a look at HttpTransportsDefault shows the following code:
// We use 0 as the default value of the MaxPendingAccepts property on
|How to pass a certificate to WSTrust to get Saml Token|
Use the ClientCertificate property:
var stsBinding = new WS2007HttpBinding();
stsBinding.Security.Message.EstablishSecurityContext = false;
stsBinding.Security.Message.NegotiateServiceCredential = false;
// select the authentication mode of Client Certificate
stsBinding.Security.Message.ClientCredentialType = MessageCredenti
|WCF service with Ssl Certificate in Azure emulator|
So there are two approaches you could take:
Create a separate cloud project for each environment - This way you
could create a self-signed certificate for your development
environment and live with the warning that the certificate is not
Get a wildcard certificate for your application - This is the approach
we have taken for our application (along with the 1st one). Basically
we took a
|WCF Exposing TCP Endpoints|
Hosting TCP endpoints in a Windows Service or by using WAS which is
part of IIS 7 is an example of managed hosting.
It really depends on whether you need managed hosting or prefer more
control and want to "self host" your WCF service in a console app for
Here's a decent MSDN doc with some good info about hosting:
|QueuedDeliveryRequirements | Actual Meaning|
Very simply, when you define a service interface, eg:
public interface ISomethingService
there are no restrictions inherent in what kind of transport binding
the interface will be exposed on, and this is a good thing, as it
decouples the interface developer from having to think about how the
service will actually be deployed an
|Why Creating new session id every time in wsHttpBinding|
By default a session is initiated when channel is opened you can read
more about it here in this Sessions in WCF
AS the default value of IsInitiating parameter is true each of your
calls started a new session. Read more About it here IsInitiating and
So in your Operation contracts
public void MethodOne()
|How to check WCF data element skipped in XML?|
You are not correct in your assertion that using nillable in your
definition permits the two cases you have listed.
In fact, the nillable xsd attribute permits the construction:
which is semantically different from Postcode being either empty, or
just not present at all.
In answer to your question,
how do I check if the element "Postcode" exists in the
|passing comma separated string value to a wcf rest service|
This is the change I made in the config behaviors to sort it,
|How to avoid unnecessary objects getting initialized WCF|
Maybe I'm misunderstanding something, but why not create the handlers
in the method they're needed by? Then your implementation would look
something like this:
public class MyService
public void HandleMessage(string msg)
IHandler1 _handler = GetHandler1();
public void HandleMessage2(string msg)
IHandler2 _handler =
|Simplest way to secure Azure Web Role WCF service|
If you really want to restrict access then I would look at client
certificates. Configuring azure for client certificates seems quite
complex to detail in a single SO post so I'll refer you to this blog
post client-certificates-in-windows-azure and I'll summarize below [I
used this myself recently so I know it works]
In essence you can make your own certificates using makecert [NOTE:
you may want
|Where can I change the port of a Web Site Project (WCF) in Visual Studio 2013?|
it is as suspected. The ports have to be changed in the SLN file and
the URL in the web.config
SLN File of the solution:
VWDPort = "xxx"
Web.config of the website:
|Get/Set the account under which WCF service is hosted|
The current user can be found using:
There is an interesting impersonation library on github and available
via NuGet that should do the trick:
|Unable to log WCF Message body|
Creating another send port that uses the FILE adapter is quite easy.
Set the filter to catch the same messages that would go to Oracle
Add the same maps
This will then write a file to some location for each request, and
contain the same message body content as would be sent to the Oracle
|Issue with Load Balancing WCF Services on Server 2012 R2|
We found the issue. There was a difference between our old server and
current server environment.
We are using AWS to load balance the servers and there is a setting
"Cross Zone Load Balancing" that was enabled with the new server
Environment, and was disabled with the old server environment. The
setting ensures even load across our load balanced servers
This was quite a surprise as i was under
|WCF Rest ERR_CONNECTION_RESET not large response|
The problem was my UsageItem class, I was missing the necessary
DataContract and DataMember fields.
public class UsageItem
public UsageItem(int ItemNumber)
this.ItemNumber = ItemNumber;
|Encryption of WCF traffic without X.509 or Windows authentication|
well ... it's just that "common" property ...
x.509 is the common way to do this in your scenario, since the most
things needed for this are already there ...
but you are not limited to either windows auth or x.509 ...
take a look here:
the article describes how you can introduce your own authenticati
|OperationContext.Current.OutgoingMessageProperties in BizTalk|
You might want to take a look at WCF message inspectors.
You can implement one in a separate project and configure it as a
behavior in your send port where you would then have full control over
both the request and the reply message.
|Unable to access a Mac self hosted WCF service from Silverlight|
I was able to resolve this issue by setting up a service host and a
separate web service host for serving the access policy. I still
leveraged the code from the example referenced in the original post,
but just separated the serving of the access policy into its own web
service host instead of being an additional endpoint on the main
Uri httpUrl = new Uri("http://192.168.2.230:8
|Should I use WCF instead of DLL in c#|
Just to get started you could create one Solution that includes:
Business logic project
Web App project
Web App project and Desktop project will just reference your Business
logic project. Then(if needed) you could continue to separate Business
logic project to e.g. Data Access project, Service Layer project etc.
Then if you will feel that you need "real" WCF service it would
|Caching large objects - LocalCache performance|
LocalCache is local to the process, i.e. within the application's
process memory. If LocalCache is enabled, object fetched from cache
will also be stored in LocalCache. Every next request for that object
will be served from that LocalCache (No need to fetch from out of
process cache). However retrieving object for the first time will take
According to MSDN:
When local cache is enabled,
|Losing WCF FaultException details when using binary|
After spending quite some hours on trying to figure out what could go
wrong, I've finally made it work. Two reasons for failure, none of
The fault message class has overridden ToString method that did some
computation. Sure it was unwise to put such logic in ToString, but who
could guess this would affect just binary serialization?
FaultException constructor has an optional paramet
|Sharing port 80 for NetTcpBinding and BasicHttpBinding in IIS 8 hosted WCF service possible?|
You can share ports between multiple basicHttp bindings, or between
multiple netTcp bindings, but unfortunately you can't mix and have
both netTcp and basicHttp share a port. WCF will give you an
AddressAlreadyInUseException for that.
|Multiple DataCacheClients - Strange configuration behaviour|
Try using the following snippet:
// DataCacheFactoryConfiguration encapsulates the datacache
client section of the config.
DataCacheFactoryConfiguration dcfc1 = new
DataCacheFactory dcf1 = new DataCacheFactory(dcfc1);
DataCache dc1 = dcf1.GetDefaultCache();
Alternatively you can configure it programmatically:
|When to use CreateChannelWithActAsToken/WithIssuedToken/WithOnBehalfOfToken?|
CreateChannelWithIssuedToken uses the current process token.
CreateChannelWithOnBehalfOfToken uses an external entity (not the
current process). A service would use this to make a call "on behalf"
of whomever called the service.
CreateChannelWithActAsToken uses both the current process and the
From Window Identity Foundation FAQ
From the WS-Trust procotol standpoint:
|Setting up a streaming WCF service in sharepoint|
I answer your question indirectly as an aside to a slightly different
Catch-22 prevents streamed TCP WCF service securable by WIF; ruining
my Christmas, mental health
My answer does not deal with sharepoint specifically, but it is
applicable in your case. Essentially the gist is that the whole
challenge/response 401 exchange is not compatible with streaming
because the stream may be se
|Preemptive authentication with CustomBinding?|
I don't think you can configure WCF to pre authenticate. Your options
are to add the headers manually to each request or to build a message
inspector to do it and configure it once. Either way those settings
are not related to the binding. I guess you could write your own
custom http transport (that internally uses the regular http
transport) and add it there but not sure it worth the effort. As d