Exchange2010 二次开发 调用EWS 报http 500内部服务错误

对于500错误,只能去该exchange服务器上查看windows的应用程序日志:



详细信息如下

System.ServiceModel.ServiceHostingEnvironment+HostingManager/48948582 
   System.ServiceModel.ServiceActivationException: 由于编译过程中出现异常,无法激活服务“/EWS/exchange.asmx”。异常消息为: 此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址。参数名: item。 ---> System.ArgumentException: 此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址。参数名: item 在 System.ServiceModel.UriSchemeKeyedCollection.InsertItem(Int32 index, Uri item) 在 System.Collections.Generic.SynchronizedCollection`1.Add(T item) 在 System.ServiceModel.UriSchemeKeyedCollection..ctor(Uri[] addresses) 在 System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) 在 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) 在 System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) 在 System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath) 在 System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) 在 System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) --- 内部异常堆栈跟踪的结尾 --- 在 System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) 在 System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath) 
   w3wp 

   7052 


关键信息为:此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址。参数名: item


原因是exchange2010 追加了WCF最为中间处理服务,访问EWS下的MRSProxy.svc这个wcf服务同样提示该错误



可以确定是WCF的问题,经过相关查询,使用如下解决方案

WCF 错误:此集合已经包含方案 http 的地址。此集合中每个方案中最多只能包含一个地址。

解决方案:

     在webservice的 web.config中system.serviceModel 标签下添加如下标签项。prefix内的值根据部署的网站ip、主机名、端口号会有所不同

 

 <system.serviceModel>


    <serviceHostingEnvironment>
      <baseAddressPrefixFilters>
        <add prefix="
http://mail.thtoa.gov.cn"/>
      </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

</system.serviceModel>


web.config修改完成之后保存,重启IIS。问题解决。


exchange2010 EWS 二次开发

07-02

我现在正在做 EWS二次开发,有段代码不能获取邮件类容和邮件附件,那位大侠指点一下。rnrn/// rn /// 显示邮件rn /// rn /// 获取邮件人地址rn /// rn #region GetNewMailrn public List GetNewMail(string address)rn rn FindItemType findItemRequest = new FindItemType();rn findItemRequest.Traversal = ItemQueryTraversalType.Shallow;rn rn ItemResponseShapeType itemProperties = new ItemResponseShapeType();rn itemProperties.BaseShape = DefaultShapeNamesType.AllProperties;rn //============rn //BodyTypeResponseType btype = new BodyTypeResponseType(); rn //itemProperties.BodyType = btype;rn //============rn findItemRequest.ItemShape = itemProperties; rn EmailAddressType box = new EmailAddressType();rn //box.MailboxType = MailboxTypeType.Mailbox;rn box.EmailAddress = address;rnrn DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];rn folderIDArray[0] = new DistinguishedFolderIdType();rn folderIDArray[0].Id = DistinguishedFolderIdNameType.inbox;rn folderIDArray[0].Mailbox = box;rn rn findItemRequest.ParentFolderIds = folderIDArray;rnrn //查询条件rn RestrictionType restriction = GetMailRestrictionByUnRead();rn rn if (restriction != null)rn findItemRequest.Restriction = restriction;rnrn tryrn rn rn FindItemResponseType findItemResponse = esb.FindItem(findItemRequest);rn rn ResponseMessageType[] rmta = findItemResponse.ResponseMessages.Items;rn rn return getMail(ref rmta);rn rn catch (Exception e)rn rn throw (e);rn rn rn //获取邮件rn private List getMail(ref ResponseMessageType[] rmta)rn rn List newMails = new List(30);rn if (rmta != null)rn rn foreach (ResponseMessageType rmt in rmta)rn rn if (rmt is FindItemResponseMessageType)rn rn FindItemResponseMessageType findItemResponse = (FindItemResponseMessageType)rmt;rn if (findItemResponse.ResponseClass == ResponseClassType.Success)rn rn if (findItemResponse.RootFolder.Item is ArrayOfRealItemsType)rn rn rn ;rn ArrayOfRealItemsType obj = (ArrayOfRealItemsType)findItemResponse.RootFolder.Item;rn //---- rn rn //----rn if (obj != null && obj.Items != null)rn rn foreach (ItemType item in obj.Items)rn rn rn if (item is MessageType)rn rn MessageType message = (MessageType)item; rn if (message != null)rn rn newMails.Add(message);rn rn rn rn rn rn rn rn rn rnrn return newMails;rn rnrnrn private RestrictionType GetMailRestrictionByUnRead()rn rn RestrictionType restriction = new RestrictionType();rn IsEqualToType isEqual = new IsEqualToType();rn rn FieldURIOrConstantType _fieldURIOrConstantType = new FieldURIOrConstantType();rn ConstantValueType _constant = new ConstantValueType();rn //控制读取邮件类型rn _constant.Value = "0";rn _fieldURIOrConstantType.Item = _constant;rn rn PathToUnindexedFieldType _pathToUnindexedFieldType = new PathToUnindexedFieldType();rn _pathToUnindexedFieldType.FieldURI = UnindexedFieldURIType.messageIsRead;rn rn isEqual.FieldURIOrConstant = _fieldURIOrConstantType;rn isEqual.Item = _pathToUnindexedFieldType;rnrn restriction.Item = isEqual;rn return restriction;rn rn #endregionrn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭