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 with style="rpc"/use="encoded":
a. the call to theMessage.Headers.Add() works ok and the handler
successfully
exits the BeforeSerialize stage. The Headers collection shows the
new header
b. Sometime after BeforeSerialize exits and before the handler is
invoked for
AfterSerialize, the framework throws an exception while serializing
the header
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. ---> System.InvalidOperationException: There was
an error generating the XML document. ---> System.InvalidOperationException:
The type CustomSoapHeaderType was not expected. Use the XmlInclude or
SoapInclude attribute to specify types that are not known statically.
at
System.Xml.Serialization.XmlSerializationWriter.Wr iteReferencedElement(String
name, String ns, Object o, Type ambientType)
at
System.Xml.Serialization.XmlSerializationWriter.Wr itePotentiallyReferencingElement(String
n, String ns, Object o, Type ambientType, Boolean suppressReference, Boolean
isNullable)
Everything I've found on this exception points to using XmlInclude/SoapInclude
to resolve problems serializing child classes. But in this case, the problem
seems to be triggered by the style/use attributes of the web services
operation.
I have no control over the Web Services client or server apps. My
SoapExtension
is just sitting in the middle trying to add and look at headers.
Any ideas what might be going on? Thanks. 2 4053
I have a similar problem (InvalidOperationException) with my SOAP extension
where I add a header.
Did you ever resolve this?
I think that it may have to do with the namespace attribute on my SOAP header.
I have not found an API that allows me to set the namespace for
System.Web.Services.Protocols.SoapHeader.
If you don’t set it, it seems to be inheriting the namespace of the SOAP body.
Have you found a way to explicitly set the namespace, or did you use some
other solution?
Thanks,
Martha Borkan ma***********@hp.com
"Mike Fiedler" wrote: 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 with style="rpc"/use="encoded":
a. the call to theMessage.Headers.Add() works ok and the handler successfully exits the BeforeSerialize stage. The Headers collection shows the new header b. Sometime after BeforeSerialize exits and before the handler is invoked for AfterSerialize, the framework throws an exception while serializing the header
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type CustomSoapHeaderType was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. at System.Xml.Serialization.XmlSerializationWriter.Wr iteReferencedElement(String name, String ns, Object o, Type ambientType) at System.Xml.Serialization.XmlSerializationWriter.Wr itePotentiallyReferencingElement(String n, String ns, Object o, Type ambientType, Boolean suppressReference, Boolean isNullable)
Everything I've found on this exception points to using XmlInclude/SoapInclude to resolve problems serializing child classes. But in this case, the problem seems to be triggered by the style/use attributes of the web services operation.
I have no control over the Web Services client or server apps. My SoapExtension is just sitting in the middle trying to add and look at headers.
Any ideas what might be going on? Thanks.
Not sure if the problems are the same. Mine was very specifically a failure
calling SoapHeaderCollection.Add() inside a SoapExtension for a
rpc/encoded Web Service call. The Add() worked fine for document/literal
Web Service calls. I opened an incident and the recommendation was
"don't use rpc/encoded attributes", but that was not an option for me.
I had to work around the problem by adding the SOAP headers myself using
the XmlDocument/XmlNode APIs instead of SoapHeaderCollection.Add().
As for your question about associating a namespace with your header. If I
understand what you are asking, you can try something like this:
// Sets the xmlns and element name within the <Header>
[XmlRoot(Namespace = "http://www.mycompany.com/MyNameSpace",
ElementName = "MyElement")]
public class MyHeader : SoapHeader
{ .... }
Hope that helps some. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: muldoon |
last post by:
Americans consider having a "British accent" a sign of sophistication
and high intelligence. Many companies hire salespersons from Britain to
represent their products,etc. Question: When the...
|
by: TS |
last post by:
Hi, i have a problem validating xml against schema. I used
http://apps.gotdotnet.com/xmltools/xsdvalidator/Default.aspx validator and
it says it is fine. Can you tell me why this doesn't work?
...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |