I've got an error while updating WCF service reference in Visual Studio 2010:
There was an error downloading 'https://192.16.0.76/MyService.svc'.
The request was aborted: Could not create SSL/TLS secure channel.
Metadata contains a reference that cannot be resolved: 'https://192.16.0.76/MyService.svc'.
The HTTP request was forbidden with client authentication scheme 'Anonymous'.
The remote server returned an error: (403) Forbidden.
Two weeks ago reference update worked fine and nothing was changed in web.config file. Now I can't update service reference and add new features to the Silverlight application. I've looked for answer on the Internet and most people advice to check certificates on the developer's pc. I haven't canged any certificates fon my pc and I also add ny certificate to the local machine store as well. Maybe I should change the default certicate for Visual Studio but I can't find how to do this.
Here is my web.config file :
<source name="System.ServiceModel"
switchValue="Error,Warning"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener"
name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging"
switchValue="Warning, Error">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener,
System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
<httpRuntime executionTimeout="600" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="MyForm.Web.MyService.customBinding0"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
openTimeout="00:10:00" closeTimeout="00:10:00">
<binaryMessageEncoding/>
<httpsTransport maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
<wsHttpBinding>
<binding name="CertificateWithTransport"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
openTimeout="00:10:00" closeTimeout="00:10:00"
maxReceivedMessageSize="2147483647">
<security mode="Transport" >
<transport clientCredentialType="Certificate" />
</security>
<readerQuotas maxDepth="2640000"
maxStringContentLength="2000000000"
maxArrayLength="2000000000"
maxBytesPerRead="2000000000"
maxNameTableCharCount="2000000000" />
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service behaviorConfiguration="ServiceBehavior" name="MyForm.Web.MyService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="CertificateWithTransport"
contract="MyForm.Web.MyService" />
</service>
</services>
<diagnostics >
<messageLogging logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
/>
</diagnostics>
Any help will be appreciated.
[Upd] It seems that it can be caused by problems with certificate on my pc. How can I choose the certificate that will be used for https connection to the web service ? I've found similar topics on the internet but there were no solutions for it.
Going through WCF – 2 Way SSL Security using Certificates , might help you.
Related
I have a WCF service (server) with a method who's signature is
public void SetProfilePic(String pSession, Applicant pApplicant)
Applicant has the property:
public byte[] Photo { get; set; }
From the client I get an image and call SetProfilePic. When the image is small, approx 1cm X 1cm, it works perfectly, however, when the image is larger, 4cm X 3cm, I get the error below
"The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '01:49:59.9779945'."
I have increased the max limits in the app.config files, however I still get the same error. I am using NetTCPBinding in buffered mode. I have also tried MTOM. Both client and service are currently running on the same machine since the project is still in its initial development phase.
I have enabled message logging and tracing on both server and client side, however no further details are given in the logs, which is not very helpful.
Below please find the App.config files for both the client and server.
My experience with WCF is only for a few months. Any help is appreciated. Thanks in advance.
client app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="c:\users\...\app_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="c:\users\...\app_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding" closeTimeout="01:50:00" openTimeout="01:50:00"
receiveTimeout="01:50:00" sendTimeout="01:50:00" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession inactivityTimeout="00:20:00" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:9000/RecruitAidService"
behaviorConfiguration="endpointBehavior" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding" contract="RecruitAidClientService.IRecruitAidService"
name="NetTcpBinding" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="endpointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
service / server app.config
UpdateApplicantUpdateBy(pSession, applId);
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Verbose,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="c:\users\...\app_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp, Callstack">
<filter type="" />
</add>
<add initializeData="c:\users\...\app_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<services>
<service name="RecruitAidServer.RecruitAidService">
<clear />
<endpoint address="net.tcp://localhost:9000/RecruitAidService"
binding="netTcpBinding" bindingConfiguration="" name="NetTcpBinding"
contract="RecruitAidServer.IRecruitAidService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/RecruitAidServer/Service1/" />
</baseAddresses>
<timeouts closeTimeout="00:01:50" />
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="NetTcpBinding" closeTimeout="01:50:00" openTimeout="01:50:00"
receiveTimeout="01:50:00" sendTimeout="01:50:00" maxBufferPoolSize="21474836470000"
maxBufferSize="2147483647" maxReceivedMessageSize="21474836470000"
transferMode="Buffered" messageEncoding="Mtom">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="endpointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Service config on server side should look like
<endpoint address="net.tcp://localhost:9000/RecruitAidService"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding"
name="NetTcpBinding" behaviorConfiguration="endpointBehavior"
contract="RecruitAidServer.IRecruitAidService" />
and bindings
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding" closeTimeout="01:50:00" openTimeout="01:50:00"
receiveTimeout="01:50:00" sendTimeout="01:50:00" maxBufferPoolSize="21474836470000"
maxBufferSize="2147483647" maxReceivedMessageSize="21474836470000"
transferMode="Buffered" messageEncoding="Mtom">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
</binding>
</netTcpBinding>
</bindings>
I am working on University Management System on which i am making WCF service....
my requirement is to Secure my web service (WCF) over the internet for this someone told me use certificates but i do not know how to use certificates
i have also implemented Https protocol and i am using WshttpBinding
This is My Web.config file :-
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="d:\khurram\projectalahsaan2014\alahsaan\dal\web_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="d:\khurram\projectalahsaan2014\alahsaan\dal\web_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<connectionStrings>
<add name="DAL.Properties.Settings.ConStr" connectionString="Data Source=.\SQL2012;Initial Catalog=AlAhsaan2014;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<!--<httpRuntime maxRequestLength="2147483647" executionTimeout="3600" enable="true" />-->
<!--2147483647-->
<sessionState mode="InProc" cookieless="true" timeout="20"> </sessionState>
</system.web>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<wsHttpBinding>
<binding name="secureWsHttpBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="524288000"
messageEncoding="Mtom"> <!--500MB Download-->
<readerQuotas maxArrayLength="1572864"/> <!--1.5MB Upload-->
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<protocolMapping>
<remove scheme="https"/>
<add scheme="https" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding"/>
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="DAL.AlahsaanDSL">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="secureWsHttpBinding"
contract="DAL.IAlahsaanDSL" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
My Question is :-
What are the mechanism of Certificates?
How to Use Certificates?
Does Certificate provide (PKI) (public key infrastructure)?
Currently I'm facing a problem trying to use the EWS, the original requirement is to connect to the mail of a specific user, after that, search for a specific folder, search for a mail and then download the attachment to a specific folder to the local machine so that later it can be processed by Integration Services, I don't want to use the EWS Managed API because I don't want to install anything when migrating to the production server, right now my idea is to develop a WCF service that connects to the EWS service through the .asmx uri and that will be able to fulfill my requirement, right now I'm ok connecting to the company's EWS but I have a few doubts:
According to Microsoft: http://msdn.microsoft.com/en-us/library/exchange/bb408524(v=exchg.150).aspx they say you must add a web service reference to your project, although it only mentions VS 2005 and VS 2008 (I'm working with VS 2012), it should automatically creates the class ExchangeServiceBinding which gives you everything you need in order to impersonate an account, my first question is: why I'm not seeing this class added to my project? should I expect this is because I am using VS 2012?
ok, anyway I'm able to use some methods like getPasswordExpirationTime, but when I use the FindFolder method, I'm getting the error: "The account does not have permission to impersonate the requested user.", this is my method:
using (ExchangeServicePortTypeClient exchangeServicePortTypeClient = new ExchangeServicePortTypeClient())
{
exchangeServicePortTypeClient.ChannelFactory.Endpoint.Address = new EndpointAddress("https://email.kraft.com/EWS/Exchange.asmx");
FindFolderResponseType findFolderResponseType = null;
exchangeServicePortTypeClient.FindFolder(
new ExchangeImpersonationType
{
ConnectingSID = new ConnectingSIDType
{
Item = #"gilberto.gutierrez#mdlz.com",
ItemElementName = ItemChoiceType1.PrimarySmtpAddress
}
},
null,
new RequestServerVersion { Version = ExchangeVersionType.Exchange2010_SP2 },
null,
new FindFolderType
{
FolderShape = new FolderResponseShapeType
{
BaseShape =
DefaultShapeNamesType.Default
}
}, out findFolderResponseType);
}
I have tried to set the credentials through this:
exchangeServicePortTypeClient.ClientCredentials.Windows.ClientCredential.UserName
exchangeServicePortTypeClient.ClientCredentials.Windows.ClientCredential.Password
exchangeServicePortTypeClient.ClientCredentials.Windows.ClientCredential.Domain
exchangeServicePortTypeClient.ChannelFactory.Credentials.Windows.ClientCredential.UserName
exchangeServicePortTypeClient.ChannelFactory.Credentials.Windows.ClientCredential.Password
exchangeServicePortTypeClient.ChannelFactory.Credentials.Windows.ClientCredential.Domain
with no luck :(.
by the way, this is my wcf config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--Diagnostics section, we will only catch error and warning in production-->
<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Error, Warning">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add type="System.Diagnostics.DefaultTraceListener" name="SellOut.ExchangeWcfService">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Error, Warning">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add type="System.Diagnostics.DefaultTraceListener" name="SellOut.ExchangeWcfService">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\Users\LFH2623\Documents\SellOut\SellOut\SellOut.Hosts.ExchangeWcfService\SellOut.ExchangeWcfService_web_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="LogicalOperationStack, DateTime, Callstack">
<filter type="" />
</add>
<add initializeData="C:\Users\LFH2623\Documents\SellOut\SellOut\SellOut.Hosts.ExchangeWcfService\SellOut.ExchangeWcfService_web_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="LogicalOperationStack, DateTime, Callstack">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<!--Framework Section-->
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<!--Web section-->
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="2147483646" />
</system.web>
<!--Web server section-->
<system.webServer>
<directoryBrowse enabled="false"/>
<defaultDocument enabled="true"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<!--WS section-->
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true"
maxMessagesToLog="10000"
logMessagesAtTransportLevel="true"
logMessagesAtServiceLevel="True"
logEntireMessage="true"/>
<endToEndTracing activityTracing="false" />
</diagnostics>
<!--For the ExchangeWebService we will aply the following service and endpoint behaviors-->
<behaviors>
<serviceBehaviors>
<behavior name="ExchangeWebService">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" httpHelpPageEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
<serviceTimeouts transactionTimeout="01:00:00" />
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" maxConcurrentInstances="100"/>
<serviceDiscovery>
<announcementEndpoints>
<endpoint kind="udpAnnouncementEndpoint"></endpoint>
</announcementEndpoints>
</serviceDiscovery>
</behavior>
</serviceBehaviors>
<!-- Define the corresponding scope for the clients to find the service through resolve message -->
<endpointBehaviors>
<behavior name="ExchangeWebService">
<endpointDiscovery enabled="true">
<scopes>
<add scope="http://SellOut.ExchangeWcfService/"/>
</scopes>
</endpointDiscovery>
</behavior>
</endpointBehaviors>
</behaviors>
<!-- In case you want to scale this service -->
<standardEndpoints>
<!-- We allow the service to be discoverable through the network in an adhoc architecture through UDP -->
<udpDiscoveryEndpoint>
<standardEndpoint name="adhocDiscoveryEndpointConfiguration"
discoveryMode="Adhoc"
discoveryVersion="WSDiscovery11"
maxResponseDelay="00:00:10">
</standardEndpoint>
</udpDiscoveryEndpoint>
<!-- We allow the service to be discoverable through the network in a managed architecture -->
<discoveryEndpoint>
<standardEndpoint name="managedDiscoveryEndpoint" discoveryMode="Managed" maxResponseDelay="00:01:00"/>
</discoveryEndpoint>
<!-- We announce the service with hello & bye -->
<announcementEndpoint>
<standardEndpoint name="udpAnnouncementEndpointConfiguration"
discoveryVersion="WSDiscovery11" />
</announcementEndpoint>
</standardEndpoints>
<!--All the Kraft's clients are .net, so we will use the proprietary binary message encoding to reduce the message's size -->
<bindings>
<customBinding>
<binding name="wsHttpBindingBynaryEncoding"
closeTimeout="00:10:00"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00">
<binaryMessageEncoding>
<readerQuotas maxDepth="32"
maxStringContentLength="5242880"
maxArrayLength="2147483646"
maxBytesPerRead="4096"
maxNameTableCharCount="5242880" />
</binaryMessageEncoding>
<httpTransport
transferMode="Buffered"
maxBufferPoolSize="2147483646"
maxReceivedMessageSize="2147483646">
</httpTransport>
</binding>
</customBinding>
<basicHttpBinding>
<binding name="KraftEWS" messageEncoding="Text" transferMode="Buffered">
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<!-- We reference the Kraft EWS -->
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="KraftEWS"
contract="KraftEWS.ExchangeServicePortType"
name="ExchangeServiceBinding_ExchangeServicePortType">
</endpoint>
</client>
<!--Services section-->
<services>
<service name="SellOut.Services.Exchange.ExchangeWebService" behaviorConfiguration="ExchangeWebService">
<endpoint name="rules"
address="rules"
binding="customBinding"
bindingConfiguration="wsHttpBindingBynaryEncoding"
behaviorConfiguration="ExchangeWebService"
contract="SellOut.Contracts.Exchange.IExchangeRulesContract"/>
<endpoint name="udpDiscovery"
kind="udpDiscoveryEndpoint"
endpointConfiguration="adhocDiscoveryEndpointConfiguration" />
<endpoint name="mex"
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
another thing to mention, in this config:
<basicHttpBinding>
<binding name="KraftEWS" messageEncoding="Text" transferMode="Buffered">
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"></transport>
</security>
</binding>
</basicHttpBinding>
if I remove the part client credential type "Windows", when trying to run the service the exception is :
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
can you guys give me a hand.
Thanks in advice.
I highly suggest that you use the EWS Managed API for this. I don't understand what you mean when you state that you don't want to install anything on the production server since you will have to install the WCF service on your production server, along with the object model created by the Add Web Service reference project. But, it looks like you got passed this part, so let's move on....
Excellent, good to know that you could call getPassowrdExpirationTime. Thank you for providing me that info.
The reason why you get the message "The account does not have permission to impersonate the requested user" is because the account that runs your WCF service doesn't have impersonation rights to the mailbox. You will need to setup Exchange impersonation before your service account can access the user's account. Once your service has credentials that Exchange can lookup in AD (which it already does), and it has rights to impersonate your users (which is on your TODO list), your code should work since authentication is done based on the service account's identity.
All parts of your question after your code example are not in scope. You don't need to make any changes to the web.config (at least I don't think so). I assume that you are testing against an on-premise server since the Auth schemes were Negotiate and NTLM.
With regards,
The article you linked to
I'm unable to get trace log file for WCF service on server. The file simply doesn't appear after I call the service.
I have no problem to get it on client with same configuration.
I'm using windows Windows Web Server 2008 R2, .net 4.0 and the service is hosted in IIS
My Config file:
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="C:\tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<diagnostics wmiProviderEnabled="true">
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<behaviors>
<endpointBehaviors>
<behavior name="Beh">
<dataContractSerializer maxItemsInObjectGraph="10000000"/>
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="WebBinding" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferSize="655360000" maxBufferPoolSize="524288000"
maxReceivedMessageSize="655360000">
<readerQuotas maxDepth="500000000" maxStringContentLength="500000000"
maxArrayLength="500000000" maxBytesPerRead="500000000" maxNameTableCharCount="500000000" />
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="ServiceBehavior" name="WcfService1.PleasureKraftService">
<clear />
<endpoint behaviorConfiguration="Beh" binding="webHttpBinding"
bindingConfiguration="WebBinding" name="Basic" contract="WcfService1.IMyService"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="WcfService1.IMyService" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.web>
<compilation debug="false"/>
<httpRuntime maxRequestLength="52428800" />
</system.web>
<connectionStrings>
<add name="Ent" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=xxxxxx;Initial Catalog=Eu;User ID=xxxx;Password=xxxx;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
</configuration>
Check if IIS has read/write access on the logging folder. From config it looks like you are logging on C$. IIS User should have read-write access on the log folder (give MachineName\User account Modify access on the folder). Also please move your logging to some folder instead of C$.
Hope this helps.
Error :
Could not find default endpoint element that references contract
'LDServiceHost.ILDService' in the ServiceModel client configuration
section. This might be because no configuration file was found for
your application, or because no endpoint element matching this
contract could be found in the client element.
App.Config :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\_Demos\EF Code Samples\EFLayers\LDPresentation\app_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="C:\_Demos\EF Code Samples\EFLayers\LDPresentation\app_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ILDService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<client>
<endpoint address="http://localhost:8732/Design_Time_Addresses/LibraryService/LDService/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ILDService"
contract="LDServiceHost.ILDService" name="WSHttpBinding_ILDService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
How to solve?
Your configuration is in a library project. Config files are application not library specific in .NET so the config needs to be in in the .exe not in the DLL
Copy the system.serviceModel section of your DLLs config into a config file for your application and it should find it OK
Btw: Its generally better to keep a question all in one place rather than add links to external sites - these have a habit of getting out of sync with SO and so the question ends up not making much sense