2 回答
TA贡献1834条经验 获得超8个赞
异常中描述的问题在于soap消息中sObject的以下类型和命名空间声明
<sObject xsi:type=\"sf:Contact\" xmlns:sf=\"urn:sobject.enterprise.soap.sforce.com\">
因为在该命名空间(或任何其他)中没有定义类 Contact。
如果您从肥皂消息中的 sObject 中删除类型和命名空间声明(并从其成员中删除 sf: 前缀),它应该可以正常工作。
或删除xsi:type=\"sf:Contact\并将 DataContract 更改为
[DataContract(Name = "sObject", Namespace = "urn:sobject.enterprise.soap.sforce.com")]
或者留下肥皂信息,然后改变
[DataContract(Name = "sObject", Namespace = "http://soap.sforce.com/2005/09/outbound")]
public class SObject
至
[DataContract(Name = "Contact", Namespace = "urn:sobject.enterprise.soap.sforce.com")]
public class Contact
也在变化(在通知中)
[DataMember(Name = "sObject", Order = 2)]
public SObject SObject { get; set; }
至
[DataMember(Name = "sObject", Order = 2)]
public Contact SObject { get; set; }
TA贡献1810条经验 获得超4个赞
您只需在 DataContract 中声明一个命名空间“ http://soap.sforce.com/2005/09/outbound ”,您可以使用 Message.CreateMessage 序列化您的通知并将您的 xml 与序列化消息进行比较。
下面是代码。
static void Main(string[] args)
{
Notifications notifications = new Notifications()
{
ActionId = "actionId",
EnterpriseUrl = "enterpriceUri",
PartnerUrl = "parentUri",
Notification = new Notification
{
Id = "abc",
SObject = new SObject
{
Email = "email",
Id = "id",
Sf = "sf",
Student_ID__c = "a",
Type = "type"
}
}
};
Message me = Message.CreateMessage(MessageVersion.Soap11, "www.abc.com", notifications); // create a message and serialize the notifications into the message
WriteMessage(me, @"d:\message.xml");
}
static void WriteMessage(Message message, string fileName)
{
using (XmlWriter writer = new XmlTextWriter(fileName, Encoding.UTF8))
{
message.WriteMessage(writer);// write the message into a file
}
Process.Start(fileName);// show the file
}
和序列化的消息。
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">www.abc.com</Action></s:Header><s:Body><notifications xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://soap.sforce.com/2005/09/outbound"><ActionId>actionId</ActionId><EnterpriseUrl>enterpriceUri</EnterpriseUrl><PartnerUrl>parentUri</PartnerUrl><Notification><Id>abc</Id><sObject><Id>id</Id><Email>email</Email><Student_ID__c>a</Student_ID__c><type>type</type><sf>sf</sf></sObject></Notification></notifications></s:Body></s:Envelope>
- 2 回答
- 0 关注
- 231 浏览
添加回答
举报