473,734 Members | 2,514 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 3466
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
3825
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 element) without Parent property serialized, this may be done by adding XmlIgnoreAttribute on the...
4
3133
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
2342
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 see server returned a correct SOAP message, but the C# client failed to deserialize the XML...
1
4489
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
9796
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 fails and gives me the following error: Binary stream does not contain a valid BinaryHeader, 0...
0
1252
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 nested objects, collections, ...). I think this process will work very well, also the
0
1142
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, containig attributes like name, age and so on and I want to show that info in the webpage. OK, the...
5
6028
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 GAC (no policy redirects exist).
2
9472
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
8777
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9452
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9184
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8187
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6737
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4551
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4813
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3262
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
3
2180
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.