开发者

Webservice to apply XSLT to response before sending?

I have a basic asp.net webservice that returns a simple response. To make it ucore com开发者_如何学Pythonpliant I need to apply an XSLT. Is there a way to apply an XSLT to my response?

I'm aware the receiver can apply it on their end, but in this scenario I need to apply it on my end.

Thanks!


See Custom Message Formatters.

Ignore ASMX web services. They have very little extensibility and are now considered to be "legacy technology" by Microsoft.


Whether you're talking about legacy ASMX or the current WCF web services, you're talking about controlling the serialized XML on output. Both the ASMX and WCF handlers by default will fire the serialization routines for the underlying objects used in their respective web service methods.

You could do it if you want to work outside the construct of serialized XML. Your method could return a string which is nothing more than the output of your method. You would need to:

  1. Go through the logic of building your resultant object
  2. Serialize the object to XML -- as a string
  3. Run an XSL transformation on the XML to an output stream
  4. Return the output stream's contents from your method

This is an extremely lousy hack, though.

EDIT: per John's reference, focus on solving this through control of the output XML. If you're using legacy ASMX, this is basic XML serialization. If you're using WCF, there are greater formatting options available.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜