SoapHeader error in the Compact .NET Framework

H

Henrik Dahl

Let's assume I make a SoapHeader in my WebService as e.g. class A:
SoapHeader{} and a specialized SoapHeader: class B : A {}. If I've declared
the SoapHeader in the .asmx file to be of type A and pass a B to it, the
instance of B does not get marshalled. Instead the header is just null on
the WebService side. This error only exists in the Compact .NET Framework.
In the complete .NET Framework it works correct, i.e. marshalls the B
instance. I use the XmlInclude(typeof(B)) attribute on A of course.

Do some of you have a suggestion for how to overcome this shortcoming?


Best regards,

Henrik Dahl
 
C

casey chesnut

i recreated this with these SoapHeaders:
public class MyParentHeader : SoapHeader
{
public string MyParentValue;
}
public class MyChildHeader : MyParentHeader
{
public string MyChildValue;
}

calling it from CF, the SoapHeader was:
<MyChildHeader xmlns="http://tempuri.org/">
<MyChildValue>child</MyChildValue>
<MyParentValue>parent</MyParentValue>
</MyChildHeader>

from the full framework, it was:
<MyParentHeader xsi:type="MyChildHeader" xmlns="http://tempuri.org/">
<MyParentValue>parent</MyParentValue>
<MyChildValue>child</MyChildValue>
</MyParentHeader>

so you can see that they are not shaped the same.
this is probably a bug in the XmlSerializer.
(i tested on a PPC 2003 device, which i think has SP2 installed?)

if you decorate the client web reference proxy with this line too, this it
gets a little closer.
[System.Xml.Serialization.XmlRootAttribute(Namespace =
"http://tempuri.org/", ElementName = "MyParentHeader", DataType =
"MyChildHeader", IsNullable=true)]
this will name the out SoapHeader 'MyParentHeader' instead of
'MyChildHeader'.
the only part left is to get it to render the attribute
xsi:type="MyChildHeader' as well.
one of the XmlAttributes or SoapAttributes should hopefully do that?

if you cant get that to work, then you can always do it through a
SoapExtension.

Thanks,
casey
http://www.brains-N-brawn.com
 
H

Henrik Dahl

So it's probably this I'm hit by. How do you actually see what the SOAP
client sends to the server?


Best regards,

Henrik Dahl

casey chesnut said:
i recreated this with these SoapHeaders:
public class MyParentHeader : SoapHeader
{
public string MyParentValue;
}
public class MyChildHeader : MyParentHeader
{
public string MyChildValue;
}

calling it from CF, the SoapHeader was:
<MyChildHeader xmlns="http://tempuri.org/">
<MyChildValue>child</MyChildValue>
<MyParentValue>parent</MyParentValue>
</MyChildHeader>

from the full framework, it was:
<MyParentHeader xsi:type="MyChildHeader" xmlns="http://tempuri.org/">
<MyParentValue>parent</MyParentValue>
<MyChildValue>child</MyChildValue>
</MyParentHeader>

so you can see that they are not shaped the same.
this is probably a bug in the XmlSerializer.
(i tested on a PPC 2003 device, which i think has SP2 installed?)

if you decorate the client web reference proxy with this line too, this it
gets a little closer.
[System.Xml.Serialization.XmlRootAttribute(Namespace =
"http://tempuri.org/", ElementName = "MyParentHeader", DataType =
"MyChildHeader", IsNullable=true)]
this will name the out SoapHeader 'MyParentHeader' instead of
'MyChildHeader'.
the only part left is to get it to render the attribute
xsi:type="MyChildHeader' as well.
one of the XmlAttributes or SoapAttributes should hopefully do that?

if you cant get that to work, then you can always do it through a
SoapExtension.

Thanks,
casey
http://www.brains-N-brawn.com


Henrik Dahl said:
Let's assume I make a SoapHeader in my WebService as e.g. class A:
SoapHeader{} and a specialized SoapHeader: class B : A {}. If I've declared
the SoapHeader in the .asmx file to be of type A and pass a B to it, the
instance of B does not get marshalled. Instead the header is just null on
the WebService side. This error only exists in the Compact .NET Framework.
In the complete .NET Framework it works correct, i.e. marshalls the B
instance. I use the XmlInclude(typeof(B)) attribute on A of course.

Do some of you have a suggestion for how to overcome this shortcoming?


Best regards,

Henrik Dahl
 
C

casey chesnut

there are a number of tools for tracing what messages are sent:
i mainly use the 'Trace Utility' with the Soap Toolkit.
PcapTrace at PocketSoap.com is another one.
there is a new one i want to try called 'Fiddler'

also, you can use a Trace SoapExtension to log client or server side.
the MSDN documentation has this code as a sample
(for the SoapExtension class)

Thanks,
casey
http://www.brains-N-brawn.com


Henrik Dahl said:
So it's probably this I'm hit by. How do you actually see what the SOAP
client sends to the server?


Best regards,

Henrik Dahl

i recreated this with these SoapHeaders:
public class MyParentHeader : SoapHeader
{
public string MyParentValue;
}
public class MyChildHeader : MyParentHeader
{
public string MyChildValue;
}

calling it from CF, the SoapHeader was:
<MyChildHeader xmlns="http://tempuri.org/">
<MyChildValue>child</MyChildValue>
<MyParentValue>parent</MyParentValue>
</MyChildHeader>

from the full framework, it was:
<MyParentHeader xsi:type="MyChildHeader" xmlns="http://tempuri.org/">
<MyParentValue>parent</MyParentValue>
<MyChildValue>child</MyChildValue>
</MyParentHeader>

so you can see that they are not shaped the same.
this is probably a bug in the XmlSerializer.
(i tested on a PPC 2003 device, which i think has SP2 installed?)

if you decorate the client web reference proxy with this line too, this it
gets a little closer.
[System.Xml.Serialization.XmlRootAttribute(Namespace =
"http://tempuri.org/", ElementName = "MyParentHeader", DataType =
"MyChildHeader", IsNullable=true)]
this will name the out SoapHeader 'MyParentHeader' instead of
'MyChildHeader'.
the only part left is to get it to render the attribute
xsi:type="MyChildHeader' as well.
one of the XmlAttributes or SoapAttributes should hopefully do that?

if you cant get that to work, then you can always do it through a
SoapExtension.

Thanks,
casey
http://www.brains-N-brawn.com


Henrik Dahl said:
Let's assume I make a SoapHeader in my WebService as e.g. class A:
SoapHeader{} and a specialized SoapHeader: class B : A {}. If I've declared
the SoapHeader in the .asmx file to be of type A and pass a B to it, the
instance of B does not get marshalled. Instead the header is just null on
the WebService side. This error only exists in the Compact .NET Framework.
In the complete .NET Framework it works correct, i.e. marshalls the B
instance. I use the XmlInclude(typeof(B)) attribute on A of course.

Do some of you have a suggestion for how to overcome this shortcoming?


Best regards,

Henrik Dahl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top