当我们尝试通过代码访问配置文件时,我们收到如下消息,请告知
错误是:
There was an error in serializing one of the headers in message
EPS_ProfileReadRQRequest: 'Unable to generate a temporary class (result=1).
错误 CS0030: 无法转换类型"CRM。ProfileReadRQ.BusinessSystemIdentityInfoSynchronizationCriterionTypeExcludeComb' to 'CRM.ProfileReadRQ.BusinessSystemIdentityInfoSynchronizationCriterionTypeIncludeComb' 错误 CS0029:无法隐式转换类型"CRM"。ProfileReadRQ.BusinessSystemIdentityInfoSynchronizationCriterionTypeIncludeComb' to 'CRM.ProfileReadRQ.BusinessSystemIdentityInfoSynchronizationCriterionTypeExcludeComb'
发生这种情况是因为序列化程序不知道要强制转换为哪种类型,因为引发错误的类型可以是多个类型。我认为这简化了XML,但它使WSDL/.NET的东西更加复杂。我可能说得并不完全准确,但这就是它的要点,至少据我所知。
您可以进入您的 reference.cs 文件并删除这些违规字段的序列化,然后重试。我过去做过这件事,并取得了一些成功。但是,如果您/当您使用新的 WSDL 文件更新 API 版本时,您必须记住再次执行此操作,因此这不是一个完美的解决方案。我有一个从参考.cs文件中删除的内容的示例,以获取下面的配置文件 API 之一,希望它对您有所帮助。
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.7.3056.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.sabre.com/eps/schemas")]
public partial class BusinessSystemIdentityInfoSynchronizationCriterionType {
private BusinessSystemIdentityInfoSynchronizationCriterionTypeExcludeCombination[] itemsField;
private ItemsChoiceType1[] itemsElementNameField;
//remarked this out 12/24/18 - these include/exclude combinations do not serialize correctly for some reason
/// <remarks/>
//[System.Xml.Serialization.XmlElementAttribute("ExcludeCombination", typeof(BusinessSystemIdentityInfoSynchronizationCriterionTypeExcludeCombination))]
//[System.Xml.Serialization.XmlElementAttribute("IncludeCombination", typeof(BusinessSystemIdentityInfoSynchronizationCriterionTypeIncludeCombination))]
//[System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
//public BusinessSystemIdentityInfoSynchronizationCriterionTypeExcludeCombination[] Items {
// get {
// return this.itemsField;
// }
// set {
// this.itemsField = value;
// }
//}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
[System.Xml.Serialization.XmlIgnoreAttribute()]
public ItemsChoiceType1[] ItemsElementName {
get {
return this.itemsElementNameField;
}
set {
this.itemsElementNameField = value;
}
}
}