Error with arguements of System.Xml.Xsl.XslTransform during webrequest

AronChan
Member Posts: 9
Hi Everybody
Im trying to process a webrequest in NAV2017 with System Dotnet variables.
Im currently trying to implement this: http://forum.mibuso.com/discussion/63741/dotnet-for-webrequest - More specificly the part where i strip the response of namespace and soap.
However im having some issues with the Transform function getting the following error:
A call to System.Xml.Xsl.XslTransform.Transform failed with this message: The type of one or more arguments does not match the method's parameter type.
My RemoveNameSpace function looks like this:
Parameters:
Local variables:
Code:
Any directions as to why this fails would be greatly appreciated?
Im trying to process a webrequest in NAV2017 with System Dotnet variables.
Im currently trying to implement this: http://forum.mibuso.com/discussion/63741/dotnet-for-webrequest - More specificly the part where i strip the response of namespace and soap.
However im having some issues with the Transform function getting the following error:
A call to System.Xml.Xsl.XslTransform.Transform failed with this message: The type of one or more arguments does not match the method's parameter type.
My RemoveNameSpace function looks like this:
Parameters:
Var Name DataType Subtype Length No Source DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Yes Destination DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Local variables:
Name DataType Subtype Length XslTransform DotNet System.Xml.Xsl.XslTransform.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XmlStyleSheet DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Writer DotNet System.IO.StringWriter.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XsltNullArgs DotNet System.Xml.Xsl.XsltArgumentList.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XsltNullArgs2 DotNet System.Xml.Xsl.XsltArgumentList.'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Code:
XslTransform := XslTransform.XslTransform; XmlStyleSheet := XmlStyleSheet.XmlDocument; XmlStyleSheet.InnerXml( '<?xml version="1.0" encoding="UTF-8"?>' + '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' + '<xsl:output method="xml" encoding="UTF-8" />' + '<xsl:template match="/">' + '<xsl:copy>' + '<xsl:apply-templates />' + '</xsl:copy>' + '</xsl:template>' + '<xsl:template match="*">' + '<xsl:element name="{local-name()}">' + '<xsl:apply-templates select="@* | node()" />' + '</xsl:element>' + '</xsl:template>' + '<xsl:template match="@*">' + '<xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute>' + '</xsl:template>' + '<xsl:template match="text() | processing-instruction() | comment()">' + '<xsl:copy />' + '</xsl:template>' + '</xsl:stylesheet>' ); XslTransform.Load(XmlStyleSheet); Writer := Writer.StringWriter; XslTransform.Transform(Source,XsltNullArgs2,Writer); Destination := Destination.XmlDocument; Destination.InnerXml(Writer.ToString);
Any directions as to why this fails would be greatly appreciated?
0
Answers
-
Because of the different .Net-version?
My version does this job slightly different, but with the same (expected) result:LOCAL RemoveXMLNamespaces(VAR pContentContainer : TEMPORARY Record TempBlob) pContentContainer.Blob.CREATEINSTREAM(ContainerInStream, TEXTENCODING::UTF8); pContentContainer.Blob.CREATEOUTSTREAM(ContainerOutStream, TEXTENCODING::UTF8); ContainerInStream.READ(ContainerText); IF ISNULL(XMLStyleSheet) THEN XMLStyleSheet := XMLStyleSheet.DOMDocumentClass; IF ISNULL(XMLSourceDocument) THEN XMLSourceDocument := XMLSourceDocument.DOMDocumentClass; IF ISNULL(XMLDestinationDocument) THEN XMLDestinationDocument := XMLDestinationDocument.DOMDocumentClass; XMLStyleSheet.loadXML(XSL_Convert); XMLSourceDocument.loadXML(ContainerText); XMLSourceDocument.transformNodeToObject(XMLStyleSheet,XMLDestinationDocument); CLEAR(pContentContainer.Blob); ContainerOutStream.WRITETEXT(XMLDestinationDocument.xml);
Variables:Name DataType Subtype Length XMLStyleSheet DotNet MSXML.DOMDocumentClass.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' XMLSourceDocument DotNet MSXML.DOMDocumentClass.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' XMLDestinationDocument DotNet MSXML.DOMDocumentClass.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ContainerInStream InStream ContainerOutStream OutStream ContainerText Text
Textconstant:Name ConstValue XSL_Convert <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="UTF-8" indent="yes" /><xsl:strip-space elements="*"/><xsl:template match="/"><xsl:copy><xsl:apply-templates /></xsl:copy></xsl:template><xsl:template match="*"><xsl:element name="{local-name()}"><xsl:apply-templates select="@* | node()" /></xsl:element></xsl:template><xsl:template match="@*"><xsl:attribute name="{local-name()}"><xsl:value-of select="."/></xsl:attribute></xsl:template><xsl:template match="text() | processing-instruction() | comment()"><xsl:copy /></xsl:template></xsl:stylesheet>
My blog - https://www.HannesHolst.com/0 -
HannesHolst thanks for replying. However you are using the Office XML variables. I am trying to avoid using anything but the standard DotNet variables so that my code is not dependant on a paid product.0
-
That's an interesting concern. I didn't think about it before.
But anyway, the MSXML-components are shipped with .Net Framework since Version 3:MSXML 6.0 MSXML6 is the latest MSXML product from Microsoft, and (along with MSXML3) is shipped with Microsoft SQL Server 2005, Visual Studio 2005, .NET Framework 3.0, Windows Vista, Windows 7 and Windows XP Service Pack 3. It also has support for native 64-bit environments. It is an upgrade but not replacement for versions 3 and 4 as they still provide legacy features not supported in version 6.[dubious – discuss] Version 6, 4, and 3 may all be installed and running concurrently. MSXML 6 is not supported on Windows 9x. Windows XP SP3 includes MSXML 6.0 SP2.
Cheers,My blog - https://www.HannesHolst.com/0 -
If a newer version of office is installed your references are no longer valid. So i want to use the System components0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions