2008-11-03 73 views
0

尝试创建函数时出现问题,作为返回类型值(Microsoft.XLANGs.BaseTypes.XLANGMessage)的BizTalk帮助器类的一部分。功能代码如下:返回值类型Microsoft.XLANGs.BaseTypes.XLANGMessage

public XLANGMessage UpdateXML (XLANGMessage inputFile) 
{ 
    XmlDocument xDoc = new XmlDocument(); 
    XLANGMessage outputFile; 
    xDoc = (System.Xml.XmlDocument) inputFile[0].RetrieveAs(typeof(System.Xml.XmlDocument)); 

    // Modify xDoc document code here 

    outputFile[0].LoadFrom(xDoc.ToString()); 
    return outputFile; 
} 

我收到一个错误,指出“未分配的局部变量 ‘OUTPUTFILE’的使用此代码不能建立我试图初始化‘OUTPUTFILE’使用new关键字(。 。=新的....),但也导致生成错误

我在做什么错

回答

2

在您所提供的代码,更改行:

XLANGMessage outputFile; 

到:

XLANGMessage outputFile = null; 

,改变TypeOftypeof

你可能想看看这两个博客文章herehere既提立足于做这包括通过类的一些更好的方法您的xsd而不是XLANGMessage,并使用流而不是XMLDocument


做一个快速一旦超过这个(因为我有一种不好的感觉)之后,我不知道的BizTalk会消耗你试图返回XLANGMessage的方式。当我尝试在我的测试工具中使用它时,它会失败并出现未构造错误。今晚晚些时候,当我有一些空闲时间时,我会看看是否有一种简单的方法直接在编排形状中使用XLANGMessage。如果您在更新之前设法使其正常工作,请添加评论。