[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] The data at the root level is invalid+xslt


Subject: [xsl] The data at the root level is invalid+xslt
From: ram <ram_kurra@xxxxxxxxxxx>
Date: Wed, 22 Feb 2012 01:31:32 +0530 (IST)

Hi,
     I have soap request in which i am stripping off some of the elements in
the soap header elements and adding wssecurity elements and activityId.
   I am not touching the soap body. i was just copying it.


Here is my sample xml

<soapenv:Envelope xmlns:tri="http://abc.com/WebServices.Common"
xmlns:ns="http://abc.com/Case/471" xmlns:con="http://xyz.com/eb/context"
xmlns:head="http://xyz.com/eb/header"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
	<soapenv:Header>
		<head:ESBHeader>
			<head:ESBProps>
				<head:Property>
					<head:name>?</head:name>
					<head:value>?</head:value>
				</head:Property>
			</head:ESBProps>

		</head:ESBHeader>
		<con:Context>
			<con:clientReqId>?</con:clientReqId>
			<con:transId>?</con:transId>
			<con:msgTyp>?</con:msgTyp>
			<con:Security>
				<con:UsernameToken>
					<con:username></con:username>
					<con:password>1</con:password>

				</con:UsernameToken>
			</con:Security>

		</con:Context>
	</soapenv:Header>
	<soapenv:Body>
		<ns:SearchCases>
			<ns:request>
				<tri:SessionId>?</tri:SessionId>
				<ns:Member>
					<ns:MemberId>?</ns:MemberId>
					<ns:SystemId>?</ns:SystemId>
				</ns:ExternalMember>
				<ns:Pagination>
					<ns:CurrentPageNumber>?</ns:CurrentPageNumber>

			</ns:request>
		</ns:SearchCases>
	</soapenv:Body>
</soapenv:Envelope>


Hers is my code

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xalan="http://xml.apache.org/xslt"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
exclude-result-prefixes="soapenv dp">	<xsl:output method="xml"
omit-xml-declaration="no"/>
	<xsl:template match="/">
		<xsl:copy>
			<xsl:apply-templates select="@*|node()"/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="soapenv:Header">
		<xsl:copy>
			<xsl:copy-of select="@*"/>
			<xsl:variable name="username">
				<xsl:value-of
select="/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='
Context']/*[local-name()='Security']/*[local-name()='UsernameToken']/*[local-
name()='username']"/>
			</xsl:variable>
			<xsl:variable name="password">
				<xsl:value-of
select="/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='
Context']/*[local-name()='Security']/*[local-name()='UsernameToken']/*[local-
name()='password']"/>
			</xsl:variable>
			<xsl:variable name="transactionId">
				<xsl:value-of
select="/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='
Context']/*[local-name()='transId']"/>
			</xsl:variable>
						<ActivityId CorrelationId=""
xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">
				<xsl:value-of select="$transactionId"/>
			</ActivityId>
			<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurit
y-secext-1.0.xsd">
				<wsse:UsernameToken>
					<wsse:Username>
						<xsl:value-of select="$username"/>
					</wsse:Username>
					<wsse:Password>
						<xsl:value-of select="$password"/>
					</wsse:Password>
				</wsse:UsernameToken>
			</wsse:Security>
		</xsl:copy>
			</xsl:template>
	<xsl:template
match="/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='E
SBHeader'] "/>
	<xsl:template
match="/*[local-name()='Envelope']/*[local-name()='Header']/*[local-name()='C
ontext'] "/>
<xsl:template match="*">
		<xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
			<xsl:copy-of select="@*"/>
			<xsl:apply-templates/>
		</xsl:element>
	</xsl:template>
</xsl:stylesheet>

When try to hit the backend service i am gettign the following error msgs
  I am getting the following error msg

<s:Body><s:Fault><faultcode
xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundat
ion/dispatcher">a:DeserializationFailed</faultcode><faultstring
xml:lang="en-US">The formatter threw an exception while trying to deserialize
the message: Error in deserializing body of request message for operation
'SearchCases'. The data at the root level is invalid. Line 69, position
4.</faultstring>

    So what exactly is the problem, am doing any mistake
The data at the root level is invalid. Line 69, position 4


Current Thread
Keywords
xml