473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot access Soapheader in SoapExtension

I have a problem accessing my custom SoapHeader from a SoapExtension. My
extension has no compile time reference to the class derived from
SoapHeader, so how can cast it into a SoapHeader of the correct type?
Thanks,

Andy
Sep 6 '06 #1
10 2201
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>I have a problem accessing my custom SoapHeader from a SoapExtension. My
extension has no compile time reference to the class derived from
SoapHeader, so how can cast it into a SoapHeader of the correct type?
XML.

John
Sep 6 '06 #2
Care to elaborate? Do you mean XML deserialization ?

"John Saunders" <john.saunder s at trizetto.comwro te in message
news:uH******** ******@TK2MSFTN GP03.phx.gbl...
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
I have a problem accessing my custom SoapHeader from a SoapExtension. My
extension has no compile time reference to the class derived from
SoapHeader, so how can cast it into a SoapHeader of the correct type?

XML.

John


Sep 7 '06 #3
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Care to elaborate? Do you mean XML deserialization ?

"John Saunders" <john.saunder s at trizetto.comwro te in message
news:uH******** ******@TK2MSFTN GP03.phx.gbl...
>"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:%2******* *********@TK2MS FTNGP05.phx.gbl ...
>I have a problem accessing my custom SoapHeader from a SoapExtension. My
extension has no compile time reference to the class derived from
SoapHeader, so how can cast it into a SoapHeader of the correct type?

XML.
Ok, I apologize. I thought I had a SOAP Extension which was accessing the
headers as XML. I was mistaken, it accesses them as a SoapHeader-derived
object.

So, to your question: I don't understand how a class, "A", without a
compile-time reference to another class, "B", could cast an object to an
instance of class "B". This question is independent of SOAP Extensions and
Headers. In fact, once it had been cast to class "B", how would class "A"
reference the methods, fields, etc., of class "B" if it has no compile-time
reference to it?

I think more detail is required.

John
Sep 7 '06 #4
Well, given that only xml data is being transferred between client and
server, I wondered if it was possible to create an identical class
definition and cast it into that. After all, normally when you create a web
service and a client VS generates the server and client proxy class and it
works fine - these two classes are not the same - i.e. No binary .dll or
similar has to be shared between client and server but you can use
DirectCast on the base class as if they were.

I tried creating an identical SoapHeader class in my SoapExtension project
in an identical namespace but it complains with "invalid cast" It makes me
wonder how the runtime knows that the xml representaion of my soapHeader
class coming over the wire is not based on the one defined in my
SoapExtension priject but on the SoapHeader defined on the web service
instead - does the deserialised XML have some kind of guid or reference to
the assembly?

I can do what I need to do by adding a reference to the web service .dll
file into my SoapExtension project, but I would rather not have that
dependancy. I also suspect you can do it with manual deserialisation (?) I
just wondered if there was an easier way.

Incidentally, I also notice there is no way to access the raw XML from the
base SoapHeader class, otherwise I would have just used that.

"John Saunders" <john.saunder s at trizetto.comwro te in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Care to elaborate? Do you mean XML deserialization ?

"John Saunders" <john.saunder s at trizetto.comwro te in message
news:uH******** ******@TK2MSFTN GP03.phx.gbl...
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
I have a problem accessing my custom SoapHeader from a SoapExtension.
My
extension has no compile time reference to the class derived from
SoapHeader, so how can cast it into a SoapHeader of the correct type?

XML.

Ok, I apologize. I thought I had a SOAP Extension which was accessing the
headers as XML. I was mistaken, it accesses them as a SoapHeader-derived
object.

So, to your question: I don't understand how a class, "A", without a
compile-time reference to another class, "B", could cast an object to an
instance of class "B". This question is independent of SOAP Extensions and
Headers. In fact, once it had been cast to class "B", how would class "A"
reference the methods, fields, etc., of class "B" if it has no
compile-time
reference to it?

I think more detail is required.

John


Sep 7 '06 #5
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
Well, given that only xml data is being transferred between client and
server, I wondered if it was possible to create an identical class
definition and cast it into that. After all, normally when you create a
web
service and a client VS generates the server and client proxy class and it
works fine - these two classes are not the same - i.e. No binary .dll or
similar has to be shared between client and server but you can use
DirectCast on the base class as if they were.
Ok, now, note that I haven't quite tried what I'm going to suggest. The
closest I've come to this had to do with SOAP faults.

If the SOAP Extension and the Web Service both access the same SOAP header,
then the definition of the SOAP Header should be in a common place. Perhaps
you can separate out the schema for the SOAP Header, and put the schema,
along with the code generated from the schema, into a separate project. That
project would "own" the piece of schema which defines these SOAP Headers.

This project would be referenced by the web service and by the SOAP
Extension.

I've done something similar with SOAP faults, which needed to be accessed
both by one web service and by some code common amongst several web
services. The schema, the generated classes, and the code to create
instances of the SOAP faults was all located in the common project.

I hope this helps. Please let us know how it works out. I don't yet have a
SOAP Header which is shared, but that might happen.

John
Sep 7 '06 #6
Thanks for the reply John,

I think what you suggest is the ideal way forward, however, our situation is
that the SoapExtension in question is just a temporary fix to be applied to
an existing live webservice. On the next build cycle, I think we will
seperate out as you suggest. As our SoapHeader was defined as public,
luckily I have been able to add a reference to the webservice .dll file so
it gets round the problem.

I'm still intrigued as to how visual studio/ASP.NET does it though. I mean,
in a normal visual studio scenario, you create you webservice with any
soapheaders, then you add a reference to that service from a client app. The
proxy classes generated on the client for the soapheaders are completly
different classes from the soapheader classes on the server and yet you can
create instances of them on the client, send them accross the wire and cast
them back into the correct type on the server and it all works swimmingly.
How does the runtime know not to throw an invalid cast exception?
"John Saunders" <john.saunder s at trizetto.comwro te in message
news:e0******** ******@TK2MSFTN GP05.phx.gbl...
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
Well, given that only xml data is being transferred between client and
server, I wondered if it was possible to create an identical class
definition and cast it into that. After all, normally when you create a
web
service and a client VS generates the server and client proxy class and
it
works fine - these two classes are not the same - i.e. No binary .dll or
similar has to be shared between client and server but you can use
DirectCast on the base class as if they were.

Ok, now, note that I haven't quite tried what I'm going to suggest. The
closest I've come to this had to do with SOAP faults.

If the SOAP Extension and the Web Service both access the same SOAP
header,
then the definition of the SOAP Header should be in a common place.
Perhaps
you can separate out the schema for the SOAP Header, and put the schema,
along with the code generated from the schema, into a separate project.
That
project would "own" the piece of schema which defines these SOAP Headers.

This project would be referenced by the web service and by the SOAP
Extension.

I've done something similar with SOAP faults, which needed to be accessed
both by one web service and by some code common amongst several web
services. The schema, the generated classes, and the code to create
instances of the SOAP faults was all located in the common project.

I hope this helps. Please let us know how it works out. I don't yet have a
SOAP Header which is shared, but that might happen.

John


Sep 8 '06 #7
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:uM******** ******@TK2MSFTN GP04.phx.gbl...
Thanks for the reply John,

I think what you suggest is the ideal way forward, however, our situation
is
that the SoapExtension in question is just a temporary fix to be applied
to
an existing live webservice. On the next build cycle, I think we will
seperate out as you suggest. As our SoapHeader was defined as public,
luckily I have been able to add a reference to the webservice .dll file so
it gets round the problem.

I'm still intrigued as to how visual studio/ASP.NET does it though. I
mean,
in a normal visual studio scenario, you create you webservice with any
soapheaders, then you add a reference to that service from a client app.
The
proxy classes generated on the client for the soapheaders are completly
different classes from the soapheader classes on the server and yet you
can
create instances of them on the client, send them accross the wire and
cast
them back into the correct type on the server and it all works swimmingly.
How does the runtime know not to throw an invalid cast exception?
It doesn't know. The cast is not invalid. It does not send instances across
the wire. It serializes a client instance, sends it across the wire, then
deserializes it into a totally separate server instance, which is of a type
unrelated to the type of the client instance.

No objects are ever transmitted in web services. Just XML.

John
Sep 8 '06 #8
Sure, but then whats different about that scenario and the one I first tried
where I had an identical class definition (with same namespace) in my soap
extension project?

I know there must be something in the serialised xml telling the runtime
that the serialised soapheader represents the soapheader class defined in my
web service and not the (identical) one defined in the soapextension
assembly - but I don't know what it is.
>
It doesn't know. The cast is not invalid. It does not send instances
across
the wire. It serializes a client instance, sends it across the wire, then
deserializes it into a totally separate server instance, which is of a
type
unrelated to the type of the client instance.

No objects are ever transmitted in web services. Just XML.

John


Sep 8 '06 #9
"Andy Kendall" <no************ *@hotmail.comwr ote in message
news:uR******** ******@TK2MSFTN GP06.phx.gbl...
Sure, but then whats different about that scenario and the one I first
tried
where I had an identical class definition (with same namespace) in my soap
extension project?

I know there must be something in the serialised xml telling the runtime
that the serialised soapheader represents the soapheader class defined in
my
web service and not the (identical) one defined in the soapextension
assembly - but I don't know what it is.
I'm not sure of the step by step details, but it's something like this:

1) IIS receives a request directed at some file with a .asmx extension
2) Since there's a sctipt mapping between that extension and ASP.NET, the
request is sent to the ASP.NET worker process
3) The worker process looks at the file extension, and maps it to a
HttpHandler subclass, in this case, WebServiceHandl er (I think)
4) WebServiceHandl er opens the .asmx file and, based on its contents,
determines which WebService-derived class to use.
5) Based on the metadata on this class, it matches the incoming SOAP message
to a WebMethod
6) Based on the metadata on this WebMethod, it deserializes the SOAP message
6a) You have one or more [SoapHeader] attributes on your WebMethods, right?
6b) Each SoapHeader attribute refers to a public field in your WebService.
6c) The field has a type and maybe other attributes, which guide
deserialization of any matching SOAP headers in the message

So, no magic, just a bit of work going on in the background.

John
Sep 8 '06 #10

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

Similar topics

1
1676
by: justin_sun | last post by:
All the sample code that I can find on SoapHeader is at least one level down within a root node. However, I'm working on a project needs to create a soap header like this: <SOAP-ENV:Header> <MessageID> uuid:6B29FC40-CA47-1067-B31D-00DD010662DA </:MessageID> <To>http://abc.example</To>
1
1241
by: Sridhar, S. | last post by:
Hi all, I am working on a project which requires webservices to log information about requests that are sent to it. I have written a SoapExtension that logs client information when a request is sent to the webservice. When there are two webservices (on the same IIS machine) and both of them have the same SoapExtension class configured on to...
3
3599
by: Trevor Pinkney | last post by:
Hi, Is it possible to reference a custom SoapExtension instance from within a WebMethod? I have a SoapExtension used by several web-services for generic logging. The SoapExtension logs the ServiceId, Soap Request, Start Time, End Time etc. to the database. I need to get the Id of the row the SoapExtension inserts into the database from...
2
4072
by: Mike Fiedler | last post by:
On a client web services request, I have a SoapExtension that is adding a header to the message in the BeforeSerialize stage. If the Web Service request is for an operation with style="document"/use="literal", everything works fine - the header is added, message is serialized and all is ok. If the Web Service request is for an operation...
3
2242
by: Lucvdv | last post by:
I have a SOAP client, built upon proxy code generated by wsdl.exe from a wsdl file that was provided by the creator of a webservice. Now I want to log the raw XML that is being sent and received, but I can't find a way to get access to it under dotNet. Do I have to write my own implementation of the SOAP protocol to do this?
2
5577
by: lprisr | last post by:
Hi, I have double byte characters in the content that I am returning using Web Services. However, the encoding in the xml file returned by Web Services is utf-8 and I am unable to read the content, not even by changing browser encoding setting to the appropriate one. I implemented SoapExtension (called EncodingExtension) to rewrite the...
0
1728
by: thatsMaBoy | last post by:
Hi, I have a VB.NET 2003 web service client (EXE) that makes use of a SOAPExtension class. The client calls a web service that returns a SOAP message containing MIME encoded files. The SOAPExtension intecepts the SOAP message and extracts the MIME, before passing on the rest of the SOAP message to the client so it can process the...
3
6701
by: Peter van der veen | last post by:
Hi In my porject i use a custom header to be added to the SOAP message. I added the the custom SOAP header to the follwoing function which is in the proxy class. But when invoking the proxy for the first time i got the message Method XX cannot be reflected, where XX is the name of this function. When i remove the soapheader attribute...
0
1874
by: Fred | last post by:
I am trying to build a consumer to a webservice which use soapheader. I am using Visual Studio 2003. Please see the wsdl-file below. Why is it that the SOAPHEADER is empty when I use it int the header instead of as part of the input message? Is there a limitation of VS2003? Please any ideas are appreciated?! TIA Fred
0
7478
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7410
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...
0
7668
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. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
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
5984
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...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
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
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.