473,387 Members | 1,535 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,387 software developers and data experts.

WebService Output Problem

jlrodrigues
I have this WebService with a webmethod tha returns XML, accessed by HTTP POST...

The webservice response is:

<?xml version="1.0" encoding="utf-8"?>
XML


For XML i create a XMLDocument into whom i load this string:

"<?xml-stylesheet type='text/xsl' href='http://localhost/myxslfile.xsl' ?><ReturnValue>answer from the WS</ReturnValue>"


my example XSL file (myxslfile.xsl) contents are:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<h3><xsl:value-of select="ReturnValue" /></h3>
</xsl:template>
</xsl:stylesheet>



Therefore, the Webservice response should be:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='http://localhost/myxslfile.xsl' ?><ReturnValue>answer from the WS</ReturnValue>


BUT IT KEEPS RETURNING ONLY

<?xml version="1.0" encoding="utf-8"?>
<ReturnValue>answer from the WS</ReturnValue>


Anyone knows what happened (obviously the Webservice took off the XSL reference), and how can i add that reference to the Output?

my method declaration is:

[WebMethod()]
public XmlDocument mymethod()
{
XmlDocument Retval = new XmlDocument();
string xml = "<?xml-stylesheet type='text/xsl' href='http://localhost/myxslfile.xsl' ?>"
+ "<ReturnValue>"
+ "answer from the WS" //Response String
+ "</ReturnValue>";
Retval.LoadXml(xml);
return Retval;
}



i even forced "<?xml version='1.0' ?><?xml-stylesheet type='text/xsl' href='http://www2.projectos.local/swsws/sws_sendsms.xsl' ?>" but it always keeps comming without those declarations.

Thanks in advance
Jan 4 '07 #1
2 1260
Ok, folks, found it myself!

But, as it is a giant unanswered question, here goes the solution!

When returning a XMLDocument, the .NET removes any processing instruction from the XMLDocument, only gets the nodes!...

So, intead of returning a XMLDocument, let's play a trick to .NET!! Lets return a fragment of XML for it to append the main XML self-created Doxument. It goes like this


[WebMethod()]
public System.Xml.XmlDocumentFragment MyService()
{
XmlDocument _Xdoc = new XmlDocument();

XmlDocumentFragment Search = _Xdoc.CreateDocumentFragment();

string PItext = "type='text/xsl' href='****XSL FILE LOCATION****'";
XmlProcessingInstruction newPI = _Xdoc.CreateProcessingInstruction("xml-
stylesheet", PItext);
Search.AppendChild(newPI);

XmlNode _elem = _Xdoc.CreateNode(XmlNodeType.Element, "ReturnValue", "
http://www.domdigital.pt");
_elem.InnerText = "HELLO ANSWER!";
Search.AppendChild( _elem);

return Search;
}


Replace only ****XSL FILE LOCATION**** with your XSL file.


It solve my problem!

Cheers! Have a nice 2007!
Jan 4 '07 #2
Coldfire
289 100+
i dont know about your problem..but hope that following book might help u

http://getonebyone.googlepages.com/ASP.NEtWebServices.zip

u can find more as per requrement from

http://getonebyone.googlepages.com/lectures
http://getonebyone.googlepages.com/home
Jan 4 '07 #3

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

Similar topics

1
by: ffhansix | last post by:
Hi, I am having problems with generating a c# proxy class from a IBM websphere WSDL file, when running the wsdl.exe to create the c# proxy file command i recieve an error: Warning: one or...
2
by: Daniel Santana | last post by:
Hi again. Now I got a brand new problem using the java webservice. I'm trying to use the wsdl tool of the "Microsoft Visual Studio .Net 2003 Command Prompt"... but I got the same message when...
7
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i don´t want to filter the return value of the method, i have to pass a new instance of the...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
0
by: Tim Bücker | last post by:
Hello everyone, i?ve got a very insistent problem trying to get remote debugging running. Really hope that someone has any ideas about this topic. Although the MSDN and some popular search...
5
by: Jonathan Kay | last post by:
Hi, I'd like to my WCF webservice to work both on SSL and without. Unfortunately searching has led to dead ends, references to changes that only work on the old previous beta versions and I...
1
by: gihan | last post by:
Hi, I have a problem accessing remote webservice from my asp code. Instead of returning results, it returns list of web methods it has. Wonder where i'm doing wrong. Also note that, this is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.