我在向BizTalk Orchestration消息分配组件中的重复元素添加值时遇到问题。这就是我所做的。我为我的架构创建了一个带有XSD.exe工具的VB.net类。我还创建了一个VB.net助手类,它继承了我的架构类,并将该类作为变量添加到我的业务流程中。我正在尝试在赋值组件中创建一条新消息。将值设置为非重复元素时,它正在工作并创建消息。但我不确定如何设置重复元素的值。当我尝试使用下面的代码时,会出现错误“内部异常:对象引用未设置为对象的实例。”。错误在此行“CredentialsLookupRequestHeader.IDs [0] = CategoryValueType;”上。 CategoryValueType是一个复杂类型,可以有多个。
-Helper Class
<Serializable>
<XmlRoot("CredentialsLookupAdapterType")> _
Public Class CredentialsLookupAdapterType
Inherits CredentialsLookupRequestV1_3Type
Public Function ToXmlDocument() As XmlDocument
Dim serializer As New XmlSerializer(GetType(CredentialsLookupAdapterType), New Type() {GetType(CredentialsLookupRequestV1_3Type)})
Dim sb As New StringBuilder
serializer.Serialize(New StringWriter(sb, CultureInfo.InvariantCulture), Me)
Dim doc As New XmlDocument()
doc.LoadXml(sb.ToString)
Return doc
End Function
End Class
biztalk中的分配组件
//Create new request message
CredentialsLookupRequest = new CredentialsLookupRequest_V1_3.CredentialsLookupAdapterType();
//Create header
CredentialsLookupRequestHeader = new CredentialsLookupRequest_V1_3.OLMHeaderType();
//Header values
CredentialsLookupRequestHeader.RequestCategory = "RETRIEVE";
CredentialsLookupRequestHeader.SubmittingEntityName = "BizTalk";
//Header IDs
CategoryValueType = new CredentialsLookupRequest_V1_3.CategoryValueType();
CategoryValueType.Category = "BizTalk Orchestration ID";
CategoryValueType.Value = "BZ000001";
CredentialsLookupRequestHeader.IDs[0] = CategoryValueType;
CredentialsLookupRequestHeader.MessageCategory = "confidential";
CredentialsLookupRequest.Header = CredentialsLookupRequestHeader;
msgRequest = CredentialsLookupRequest.ToXmlDocument();
答案 0 :(得分:0)
你可以简单地使用xpath来分配一个值..不需要使用辅助函数。