Я использую C # для создания приемника событий для наблюдения за конкретным почтовым ящиком сервера обмена.
Моя реализация основана на этом примере: http://www.codeproject.com/KB/exchange/ManagedEventSinks.aspx?fid=382114&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26#xx0xx
Вместо функциональности, описанной в примере, я пытаюсь отправить определенную информацию в веб-службу.
Я использую Visual Studio, чтобы добавить ссылку на службу в мою библиотеку классов и следующий код для вызова единственного метода в веб-службе:
public void OnSave(IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags)
{
try
{
Message iMessage = new MessageClass();
iMessage.DataSource.Open(bstrURLItem, null,
ADODB.ConnectModeEnum.adModeRead,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource, "", "");
string sub= iMessage.Subject;
string body = iMessage.HTMLBody;
MyWSSoapClient wsc = new MyWSSoapClient();
wsc.SingleMethodinWS(sub, body);
}
catch (Exception ex)
{
}
}
После того, как я собрал компонент COM и добавил приемник событий в папку «Входящие» и проверил его, я получаю сообщение об ошибке:
Could not find default endpoint element that references contract 'MyWS.MyWSSoap' 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.
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase`1..ctor()
at ReplyParserEventSink.AnswerQuestionWS.AnswerQuestionWSSoapClient..ctor()
at ReplyParserEventSink.AsyncParser.OnSave(IExStoreEventInfo pEventInfo, String bstrURLItem, Int32 lFlags)
EDIT:
Это то, что я нашел в конфигурации приложения
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyWSSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<endpoint address="http://127.0.0.1/MyProject/WebService/MyWS.asmx"
binding="basicHttpBinding" bindingConfiguration="MyWSSoap"
contract="MyWS.MyWSSoap" name="MyWSSoap" />
</system.serviceModel>
@ Александр: Я пробовал то, что вы сказали, но я получаю ту же ошибку. Спасибо