В настоящее время у меня возникла проблема с попыткой использовать EWS, первоначальное требование - подключиться к почте определенного пользователя, после чего искать определенную папку, искать почту а затем загрузите вложение в определенную папку на локальный компьютер, чтобы впоследствии ее можно было обработать с помощью служб Integration Services, я не хочу использовать управляемый API EWS, потому что я не хочу ничего устанавливать при миграции на производственный сервер , прямо сейчас моя идея заключается в разработке службы WCF, которая подключается к службе EWS через urims .asmx и которая сможет выполнить мое требование, прямо сейчас я нормально подключаюсь к EWS компании, но у меня есть несколько сомнений:ExchangeServiceBinding, EWS, веб-служба Exchange
Согласно Microsoft: http://msdn.microsoft.com/en-us/library/exchange/bb408524(v=exchg.150).aspx они говорят, что вы должны добавить нас b ссылку на ваш проект, хотя он упоминает только VS 2005 и VS 2008 (я работаю с VS 2012), он должен автоматически создавать класс ExchangeServiceBinding, который дает вам все, что вам нужно, чтобы олицетворять учетную запись, мой первый вопрос: : почему я не вижу этот класс, добавленный в мой проект? Должен ли я ожидать, что это связано с тем, что я использую VS 2012?
ОК, в любом случае я могу использовать некоторые методы, такие как getPasswordExpirationTime, но когда я использую метод FindFolder, я получаю сообщение об ошибке: «У учетной записи нет разрешения выдавать себя за запрошенного пользователя». мой метод:
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 = @"[email protected]",
ItemElementName = ItemChoiceType1.PrimarySmtpAddress
}
},
null,
new RequestServerVersion { Version = ExchangeVersionType.Exchange2010_SP2 },
null,
new FindFolderType
{
FolderShape = new FolderResponseShapeType
{
BaseShape =
DefaultShapeNamesType.Default
}
}, out findFolderResponseType);
}
Я попытался установить полномочия через это:.
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
не повезло :(
, кстати, это мой ФОС конф ig файл.
<?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>
еще одна вещь, говоря, в этой конфигурации:
<basicHttpBinding>
<binding name="KraftEWS" messageEncoding="Text" transferMode="Buffered">
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"></transport>
</security>
</binding>
</basicHttpBinding>
если удалить часть клиента тип учетных данных «Windows», при попытке запуска службы исключение составляет:
HTTP-запрос неавторизован с помощью схемы аутентификации клиента «Аноним». Заголовок аутентификации, полученный с сервера, был «Negotiate, NTLM».
Можете ли вы, ребята, дать мне руку.
Спасибо за консультацию.
Спасибо за ваш ответ Майкл, установив что-нибудь на сервере я имел в виду, я не хочу, чтобы установить EWS API на сервере, сервер уже есть .NET framework 4.5 установлен, поэтому мы можем предположить, что Wcf будет работать нормально. Также я хочу сказать вам, что я нашел проблему, класс exchangechangeervicebinding не был создан автоматически, потому что вы должны добавить ссылку на службу, например, ссылку на старую службу, я имею в виду, щелкнуть расширенные свойства, а затем добавить веб-ссылку, поэтому с этим классом я смог для соединения с указанием любых учетных данных, которые я хочу, без необходимости олицетворения –
Еще Майкл, вы правы в том, что вы говорили о олицетворении в Exchange, и да, схемы Auth - переговоры и NTLM, большое спасибо Майку. –