RE: Bypassing Serialization/Deserialization in WebService/AP.NET

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Henk de Koning (HenkdeKoning_at_discussions.microsoft.com)
Date: 01/10/05


Date: Mon, 10 Jan 2005 12:31:05 -0800

Actually it turns out this is quite simple. Just use a normal web method, but
type its (one) parameter as [XmlAnyElement] XmlNode [] theBodyStuff.

Now the direct children of your <soap:body> element will be directly morphed
into the XmlNode array without deserialization.

You can process soap header like normal. Here is a prototype of a webmethod
which should do what you want. It takes any body without deserialization and
allows you to touch any header sent to it:

public class CFlexservice
{
  public SoapUnknownHeader[] _theHeaders;

  [WebMethod]
  [SoapHeader("_theHeaders", Direction=SoapHeaderDirection.InOut)]
  [return:XmlAnyElement]
  public XmlNode [] FlexMethod([XmlAnyElement] XmlNode [] _bodyStuff)
  {
    // ... your stuff here ...
  }
}

BTW, I typed this by heart, so don't trust me ;-)

HTH,

-- Henkk

"ashoksrini" wrote:

> Hi All,
>
> I have the below requirement and would like to get some feeback from the
> group on the best way to implement:
>
> 1. I have WSDL defined exposing few web services.
> 2. We dont have a requirement to have a server web service class. (reasons
> below)
> 3. I want to develop something like this - when client makes a web service
> call, on the server I can intercept the SOAP message (XML doc itself),
> inspect some headers and then get the SOAP body and then pass on the body
> (XML) to a method in another class. As you can see, there is no use of having
> a ASP.NET server class, since all my web services have to be dealt in the
> same way (i.e get the body xml and call the same method on the same class
> passing the xml).
> 4. What we are trying to avoid, is the unecessary serialization and
> deserialization that happens when web service call has to be converted to a
> service class method object and etc.
>
> Given this, one of the ways to do it is to have a custom httphandler
> (registered in web.config) and get the http request stream in the handler
> class, inspect it and pass on the body. This would imply that when the
> handler class receive the response back, then it would have to manually
> create the SOAP response XML, which would mean that the handler should
> maintain the request that came in and map the request to response etc.
> So finally my question....is it possible to do this another way, leveraging
> the ASP.NET infrastructure (creating soap response, faults etc), but without
> the additional serialization, deserialization overhead?
>
> If you have read till here, thanks for your patience
>
>
>



Relevant Pages

  • Rails Web services (in general), HTTP GET and JSON and other topics
    ... I like SOA, I like Ajax, I like Ruby/Rails, but I am in doubt how to ... Does anybody know a good tutorial about Rails Web services? ... be configured not to adhere to SOAP protocol or to use XML. ...
    (comp.lang.ruby)
  • Re: Passing an variant from classic ASP page to a .NET webservice
    ... In the end I just loaded the returned XML into an DOMObject ... and parsed the DOM object and it works a treat ... That's not how web services work. ... must be compliant with SOAP. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Trying to use Web service References in Access 2003 and need to create an authentication soap he
    ... library also means you have full xml parsing at your fingertips. ... In most cases I think the above is FAR LESS work then the soap web tool kit. ... class modules need be to added for each new method of the web service. ... changes in the web services can often break the access side of code. ...
    (comp.databases.ms-access)
  • Book Advice
    ... I currently know nothing about xml, web services and soap and I am ... I guess SOAP fits in here somewhere. ... PERL, Python and PHP. ...
    (comp.lang.php)
  • Re: Read a SOAP Message
    ... because it doesn't like the XML even though I'm pretty sure it's valid ... How can I find out what the SOAP Response my VB APP recieved was? ... Studio (F5 a web service project and you'll see what I mean) so you ...
    (microsoft.public.dotnet.languages.vb)