473,543 Members | 2,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bypassing Serialization/Deserialization in WebService/AP.NET

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

Nov 23 '05 #1
8 3449
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 SoapUnknownHead er[] _theHeaders;

[WebMethod]
[SoapHeader("_th eHeaders", Direction=SoapH eaderDirection. InOut)]
[return:XmlAnyEl ement]
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

Nov 23 '05 #2
umm...not sure if that will work.

My web services defined in WSDL will look like this (represented in .NET
class)

CreateSalesOrde r(SalesOrder)
CreatePurchaseO rder(PurchaseOr der) etc.
"Henk de Koning" wrote:
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 SoapUnknownHead er[] _theHeaders;

[WebMethod]
[SoapHeader("_th eHeaders", Direction=SoapH eaderDirection. InOut)]
[return:XmlAnyEl ement]
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

Nov 23 '05 #3
Hello Henk,
That will work provided you only have one soap action i.e. FlexMethod in
this case. However try using WSE 2.0 and use the soap receiver that can accept
any input and any action. Either way you would need to do what WSE does behind
the scenes ;)

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
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 SoapUnknownHead er[] _theHeaders;
[WebMethod]
[SoapHeader("_th eHeaders", Direction=SoapH eaderDirection. InOut)]
[return:XmlAnyEl ement]
public XmlNode [] FlexMethod([XmlAnyElement] XmlNode [] _bodyStuff)
{
// ... your stuff here ...
}
}
BTW, I typed this by heart, so don't trust me ;-)

HTH,
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

Nov 23 '05 #4
Use SoapExtension class and override othe ProcessMessage method, take a
lookt at the MSDN documentation for details

// then you can write your method someting like this, preserving the WSDL

[MyOwnSoapExtens ionAttribute]
[WebMethod]
public SalesOrderRespo nse CreateSalesOrde r(SalesOrder);
regards
erymuzuan msutapa

ashoksrini wrote:
umm...not sure if that will work.

My web services defined in WSDL will look like this (represented in .NET
class)

CreateSalesOrde r(SalesOrder)
CreatePurchaseO rder(PurchaseOr der) etc.
"Henk de Koning" wrote:

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 SoapUnknownHead er[] _theHeaders;

[WebMethod]
[SoapHeader("_th eHeaders", Direction=SoapH eaderDirection. InOut)]
[return:XmlAnyEl ement]
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
deserializat ion 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
(registere d 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

Nov 23 '05 #5
Well, the question was if it could be done using the aspnet pipeline ... I
agree you can do other stuff with WSE2, and you know what, with Indigo you
can ditch the web server entirely ;-)

Anyhow, you *can* expose multiple methods using the anyElement technique, as
long as you are willing to write the WSDL by hand (or tool, or create
skeleton webmethods first, capture the generated WSDL and then replace the
skeletons by corresponding any methods). The contract can be more strongly
typed than the implementation (or better, the typing can be enforced by
something else than the plumbing).

Remember that the only thing that determins delivery of a soap request to an
endpoint is the method name (in fact, the lack of support for overloading is
one of the big struggles in WSDL2 right now).

-- Henkk

"Dilip Krishnan" wrote:
Hello Henk,
That will work provided you only have one soap action i.e. FlexMethod in
this case. However try using WSE 2.0 and use the soap receiver that can accept
any input and any action. Either way you would need to do what WSE does behind
the scenes ;)

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
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 SoapUnknownHead er[] _theHeaders;
[WebMethod]
[SoapHeader("_th eHeaders", Direction=SoapH eaderDirection. InOut)]
[return:XmlAnyEl ement]
public XmlNode [] FlexMethod([XmlAnyElement] XmlNode [] _bodyStuff)
{
// ... your stuff here ...
}
}
BTW, I typed this by heart, so don't trust me ;-)

HTH,
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


Nov 23 '05 #6
> Well, the question was if it could be done using the aspnet pipeline
... I agree you can do other stuff with WSE2, and you know what, with
Indigo you can ditch the web server entirely ;-)
:)
Anyhow, you *can* expose multiple methods using the anyElement
You *cannot* expose multiple methods in ASP.net... only one method which
can handle many inputs!
technique, as long as you are willing to write the WSDL by hand (or
tool, or create skeleton webmethods first, capture the generated WSDL
and then replace the skeletons by corresponding any methods). The
contract can be more strongly typed than the implementation (or
better, the typing can be enforced by something else than the
plumbing).

Remember that the only thing that determins delivery of a soap request
to an endpoint is the method name (in fact, the lack of support for
overloading is one of the big struggles in WSDL2 right now).


Exactly my point!

<snip>

Nov 23 '05 #7
I am looking at a trace of a wsdl generated proxy that goes to the following
webmethods:

[WebMethod]
[SoapHeader("_my Headers", Direction=SoapH eaderDirection. InOut)]
[return:XmlAnyEl ementAttribute]
public XmlNode [] AnyMethod1([XmlAnyElement] XmlNode [] body)
{
body[0].InnerText = "Bye bye";
return body;
}

[WebMethod]
[SoapHeader("_my Headers", Direction=SoapH eaderDirection. InOut)]
[return:XmlAnyEl ementAttribute]
public XmlNode [] AnyMethod2([XmlAnyElement] XmlNode [] body)
{
return body;
}

So, I rather believe my own eyes than your remarks ;-). I stick to my point:
you *can* do multiple anyElement webmethods (as long as you give them
different names). What makes you believe this would be impossible ?

-- Henkk
"Dilip Krishnan" wrote:
Well, the question was if it could be done using the aspnet pipeline
... I agree you can do other stuff with WSE2, and you know what, with
Indigo you can ditch the web server entirely ;-)


:)
Anyhow, you *can* expose multiple methods using the anyElement


You *cannot* expose multiple methods in ASP.net... only one method which
can handle many inputs!
technique, as long as you are willing to write the WSDL by hand (or
tool, or create skeleton webmethods first, capture the generated WSDL
and then replace the skeletons by corresponding any methods). The
contract can be more strongly typed than the implementation (or
better, the typing can be enforced by something else than the
plumbing).

Remember that the only thing that determins delivery of a soap request
to an endpoint is the method name (in fact, the lack of support for
overloading is one of the big struggles in WSDL2 right now).


Exactly my point!

<snip>

Nov 23 '05 #8
Hello Henk,
Not to start an email war.. but i think we misunderstood each other.
What I tried to say was you cannot have multiple soap actions being handled
by the same web method with XmlAnyElement :) This is by virtue of the fact
that the soap action is infered from the method name if the action (SoapDocumentMe thod)Attribute
is not specified. You can by all means create as many methods as you want...
and all day. However it doesnt address the original problem

"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."

<snip>
So, I rather believe my own eyes than your remarks ;-). I stick to my
point: you *can* do multiple anyElement webmethods (as long as you
give them different names). What makes you believe this would be
impossible ?


Certainly possible ;)
Cheers!
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Nov 23 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3819
by: Snowman | last post by:
Suppose I have a RootObject which holds a collection of other objects. The other objects have a property (Parent) which refers back to the "parent" collection (b.t.w. my collection is based on CollectionBase), in similar fashion as the object models of MS Office. I want to serialize this object graph (with RootObject as the xml document...
4
3123
by: Jeff T. | last post by:
Hello, I have an existing set of C# classes that encapsulate our application data. They are in a heirachy with each subclass defining more specific types of data. I would like to serialize these data objects as XML but perserve the relationships in the XML document. For example, if my classes were: public class GenericItem { }
0
2318
by: psy000 | last post by:
Hi, I have a C# web service client that talks to a JAVA application sever. I use AXIS to generate the WSDL file, use wsdl.exe to generate proxy stub c# code. When I try to use c# client connect to application server, I did not get the result in the C# client side, I used a soap monitor to look at the SOAP messages that were exchanged, I can...
1
4471
by: Maheal | last post by:
I have been trying to Serialize an object that is the child of another object which is also serializable. Here is the simplified scenario (assume missing code is correct): class One : ISerializable { int x; int y; One() {}; // constructor One(SerializationInfo i, StreamingContext c) { // deserialization
3
9785
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database (when I check the database the field that holds the binary data seems populated), but when I want to deserialize this same byte array the application...
0
1244
by: Goethals Frederik | last post by:
Hi, I have some questions that are a little difficult to explain, so I give it a try... I have an application (aSP.NET with VB.NET codebehind) and I would like to store my data on disk because the users could continue later on there project with the same data already filled in. So I would use the soap-serialization to store the info (the...
0
1136
by: Miguel RS | last post by:
Hi all, I have a winforms app (app1), a webservice (ws1) and a webpage (wp1). The webservice exposes a type (type1). When I generate a proxy (px1) for app1 I get the type ws1.type1. The thing is that I want to serialize an instance of this type, pass it as a parameter to wp1 and then deserialize it. Let's say that type1 is a person´s info,...
5
6010
by: Harold Howe | last post by:
I am having a problem deserializing objects from a library when the following conditions exist: 1- The library is strongly named 2- The serialized file was created with version 1.0 of the assembly 3- I am trying to deserialize from an EXE that references version 2.0 of the assembly 4- Both version 1.0 and 2.0 of the assembly reside in the...
2
9465
by: =?ISO-8859-1?Q?=22Andr=E9s_G=2E_Aragoneses_=5B_kno | last post by:
Hello. I have this kind of object: class classA { int x; classA z; public int X { get { return this.x; }
0
7584
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7729
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5880
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5258
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4884
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
626
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.