473,395 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XSLT in Web Service

117 100+
i want to use the XSLT in Web Service for XML transformation, but it gives error. here is my XSL:





<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" />

<xsl:template match="/">

<html>

<body>


<xsl:for-each select="tblXXX">

<xsl:choose>

<xsl:when test="Name!=''">

<xsl:value-of select="Name" /><br />

</xsl:when>

</xsl:choose>


</xsl:for-each>

</body>

</html>

</xsl:template>

</xsl:stylesheet>





and here is the Code that i am using.


private const int CacheTime = 30;

public enum FaultCode

{

Client=0,

Server=1

}

[WebMethod(CacheDuration=CacheTime,Description="Get values from Database",EnableSession=true)]

public void GetStr(string rType)

{

try

{

string xslPath = Server.MapPath("includes/xsl/hotel.xsl");

string str = System.Configuration.ConfigurationSettings.AppSett ings["connectionString"].ToString();

SqlConnection cnn = new SqlConnection(str);

cnn.Open();

SqlCommand cmd = new SqlCommand("SELECT " + rType + " FROM tblXXX for xml auto,elements",cnn);

XmlReader reader = cmd.ExecuteXmlReader();

XPathDocument doc = new XPathDocument(reader);

cnn.Close();

XslTransform tr = new XslTransform();

tr.Load(xslPath);

tr.Transform(doc,null,System.Web.HttpContext.Curre nt.Response.Output);

reader.Close();

}

catch(SoapException soapEx)

{

throw soapEx;

}

catch(Exception ex)

{

RaiseException("GetStr","http://tempuri.org/CategoriesService",ex.Message,"1000",ex.Source,Fau ltCode.Server);

}

}





it gives this error





The <html> tag from namespace is not expected. Line 1, position 2.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Xml.XmlException: The <html> tag from namespace is not expected. Line 1, position 2.

Source Error:



Line 35: [System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://tempuri.org/GetStr", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse .Literal, ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
Line 36: public void GetStr(string rType) {
Line 37: this.Invoke("GetStr", new object[] {
Line 38: rType});
Line 39: }




Source File: c:\inetpub\wwwroot\test1\Web References\localhost\Reference.cs Line: 37




but when i test the web service projects it runs fine and gives the result only when i deploy it then it gives this error.





any solution
Mar 15 '07 #1
0 809

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ringo Langly | last post by:
Hi all, I'm a seasoned web programmer, but I've never touched XSLT. It's always been one of those acronyms I've never needed to educate myself on. Now... we're working with a web content...
1
by: Tony | last post by:
Can anyone help, can't seem to completely sus this xslt out. <Navigation> <Item name="Home" depth="1" navid="1" type="16"> <Item name="Consumers" depth="2" navid="2" type="128"> <Item...
12
by: gipsy boy | last post by:
Hello, I have sort of a big problem. I would really appreciate any help you could give me. I made a web service in C++ that throws XML to the client (browser). But, the XSLT transormation...
2
by: Sylvia | last post by:
Hi, I'm trying to render a XML structure to HTML using XSLT. My XML describe the header of a table with a complex and not linear structure. The first row of the header table always contains the...
0
by: Brendan Reynolds | last post by:
I have a web service that takes the XML representation of a dataset and uses XSLT to transform it to the format required to open a disconnected ADODB recordset on the XML, and returns the...
1
by: John Moore | last post by:
I have a set of code that is called on every page load that loads an xslt file. The xslt file has an embedded <script> tag. Loading the page mutliple times causes aspnet_wp.exe to use all available...
4
by: WStoreyII | last post by:
I wish to know how to set it up so that when an xml webservice is called that instead of displaying the xml in the browser it will render it with a xslt file the problem is i dont know how to do...
2
by: Scott Sauyet | last post by:
I'm trying to select a subset of a WSDL document using XSLT and a simple text document describing the high-level elements to include. I have it working fine for selecting the services, bindings,...
2
by: astroboiii | last post by:
New to the whole xml thing and finding w3schools to be an excellent resource. Now down to my question: I have several xml files I need to parse through and grab relevant information from and...
3
by: z1 | last post by:
hi- i am fooling around with soap and weather templates. for some reason either this if or select is failing. i am very new to xml and found this code at another site. i can show you the xml...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.