[Gelöst]System.Xml.XmlDocument.Load Fehler Stammelement
Verfasst: 23. Juni 2016 15:30
Hallo liebe Community,
ich habe ein Problem beim lesen einer XML Datei.
Folgendermaßen gehe ich vor:
Dabei kommt es zu diesem Fehler:
Das XML sieht so aus, kommt aber eben als BigText rein
Hat jemand eine Idee, woher der Fehler kommt?
In NAV2009 hat es noch funktioniert, allerdings war es da noch ein Automation und nun musste es ja auf DotNet umgebaut werden.
Vielen Dank,
Tobias
ich habe ein Problem beim lesen einer XML Datei.
Folgendermaßen gehe ich vor:
- Code:
"Request XML".CREATEOUTSTREAM(Loc_Outstream);
Loc_MessageIn.WRITE(Loc_Outstream);
IF "Request XML".HASVALUE THEN BEGIN
"Request XML".CREATEINSTREAM(XMLInStream);
XMLDOMNET := XMLDOMNET.XmlDocument();
XMLDOMNET.Load(XMLInStream);
Dabei kommt es zu diesem Fehler:
- Code:
Type: Microsoft.Dynamics.Nav.Types.Exceptions.NavNCLDotNetInvokeException
SuppressMessage: False
SuppressExceptionCreatedEvent: False
FatalityScope: Call
Message: Fehler bei einem Aufruf von System.Xml.XmlDocument.Load mit folgender Meldung: Das Stammelement ist nicht vorhanden.
StackTrace:
bei Microsoft.Dynamics.Nav.Runtime.NavDotNet.Invoke[T](String methodName, UInt32 methodIndex, BindingFlags flags, ParameterModifier modifier, Type[] referenceTypes, Object[] arguments)
bei Microsoft.Dynamics.Nav.Runtime.NavDotNet.InvokeMethod[T](Boolean isStatic, String methodName, UInt32 methodIndex, Object[] arguments)
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit51112.Fn_GetXMLFromBigText_Scope.OnRun()
bei Filter.InvokeWithFilter(NavMethodScope )
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit51112.Fn_GetXMLEnvelopeValue_Scope.OnRun()
bei Filter.InvokeWithFilter(NavMethodScope )
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit51112.Fn_GetXMLEnvelopeValue(NavBigText prm_XMLMessage, NavText prm_Node)
bei Microsoft.Dynamics.Nav.BusinessApplication.Codeunit51111.Fn_XmlRequestHandle_Scope.OnRun()
bei Filter.InvokeWithFilter(NavMethodScope )
bei Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei Microsoft.Dynamics.Nav.Runtime.TaskHelper.Rethrow(Exception exception)
bei Microsoft.Dynamics.Nav.Service.WebServices.ServiceBroker.Invoke(Boolean isSoapMessage, Uri url, XmlReader input, TextWriter output, NavUserAuthentication navUserAuth)
bei Microsoft.Dynamics.Nav.Service.WebServices.NavWebService.<>c__DisplayClass5.<>c__DisplayClass7.<ProcessMessage>b__3()
bei Microsoft.Dynamics.Nav.Service.WebServices.Disposer.Scope(Code code)
bei Microsoft.Dynamics.Nav.Service.WebServices.WCFUtil.GetPopulatedMemoryStream(StreamFillingCallback callback)
bei Microsoft.Dynamics.Nav.Service.WebServices.NavWebService.ProcessMessage(Message message)
bei SyncInvokeProcessMessage(Object , Object[] , Object[] )
bei System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
bei System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
bei System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
bei System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
bei System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
Source: Microsoft.Dynamics.Nav.Ncl
HResult: -2146233088
----------------------------------
Type: System.Xml.XmlException
LineNumber: 0
LinePosition: 0
Message: Das Stammelement ist nicht vorhanden.
StackTrace:
bei System.Xml.XmlTextReaderImpl.Throw(Exception e)
bei System.Xml.XmlTextReaderImpl.ParseDocumentContent()
bei System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
bei System.Xml.XmlDocument.Load(XmlReader reader)
bei System.Xml.XmlDocument.Load(Stream inStream)
Source: System.Xml
HResult: -2146232000
Das XML sieht so aus, kommt aber eben als BigText rein
- Code:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<Root xmlns="http://xxxxxxxxxxxxx">
<Envelope>
<MessageID>30FD98AE-CC9E-3CF0-D2D0-870F2B688F39</MessageID>
<SourceSystem>Web</SourceSystem>
<UserID>WebUser</UserID>
<DocumentType>CreateReg</DocumentType>
<DateTime>05.02.2016 08:24:30</DateTime>
</Envelope>
<Message>
<Title>Title</Title>
<Period>März - Mai 2016</Period>
<Date>21.05. - 22.05. in Wensin (Garbek)</Date>
<CourseCode>XXXX</CourseCode>
<MemberID></MemberID>
<Gender>männlich</Gender>
<FirstName>Max</FirstName>
<LastName>Mustermann</LastName>
<DateOfBirth>17.06.2008</DateOfBirth>
<Street>Musterstr</Street>
<No>1</No>
<PostCode>12345</PostCode>
<City>Musterstadt</City>
<Phone>1234567</Phone>
<MobilePhone>123457</MobilePhone>
<Size>L</Size>
<AdditionalInformation></AdditionalInformation>
<PreferedGroup></PreferedGroup>
<AccountHolder></AccountHolder>
</Message>
</Root>
Hat jemand eine Idee, woher der Fehler kommt?
In NAV2009 hat es noch funktioniert, allerdings war es da noch ein Automation und nun musste es ja auf DotNet umgebaut werden.
- Code:
IF NOT ISCLEAR(XMLDOM) THEN
CLEAR(XMLDOM);
CALCFIELDS("Request XML");
IF "Request XML".HASVALUE THEN BEGIN
"Request XML".CREATEINSTREAM(XMLInStream);
CREATE(XMLDOM);
EXIT(XMLDOM.load(XMLInStream));
END;
EXIT(FALSE);
XMLDOM Automation 'Microsoft XML, v6.0'.DOMDocument60
Vielen Dank,
Tobias