Thursday, November 13, 2008

Inconsistent "soap:mustUnderstand" in .Net 2.0

@YaronNaveh

It seems that .Net 2.0 web services do not handle soap:mustUnderstand attribute in a consistent manner. This attribute can appear over soap headers in order to require the processing party to fail itself if it cannot process this specific header. Example:


<soap:Envelope>
 <soap:Header>
  <SomeHeader soap:mustUnderstand="1">1234</SomeHeader>
 </soap:Header>
 <soap:Body>
  ...
 </soap:Body>
</soap:Envelope>


Now if our server does not understand SomeHeader an exception should be thrown.

To begin with, when a SoapHeader is defined in the service/proxy, .Net will not allow us to mark it as "required" since it is considered obsolete:



This is not really related to mustUnderstand: When the proxy contains required=true it means (or should have at least) that the proxy will fail itself if this value is not supplied by the user. This is different than omitting a mustUnderstand header which will cause the server to fail.

But the real inconsistency comes with mustUnderstand: When a .Net 2.0 web service gets soap:mustUnderstand header it will always ignore it even if it was not understood. On the other hand, when a .Net 2.0 web service client gets such an header in a response from the server it will throw the following exception:


SOAP header SomeHeader was not understood.

Be aware of this inconsistency when you build or consume .Net 2.0 web services.

@YaronNaveh

What's next? get this blog rss updates or register for mail updates!

7 comments:

Anonymous said...

And I can't tell you how frustrating it is sometimes when these little issuse pop out from nowhere. It took me a while to figure this out.

I haven't tried an implementation in 3.0 or 3.5 yet, but I'm hopeful it's fixed.

Yaron Naveh (MVP) said...

And all of these small bits are usually interoperability show stoppers...

Anonymous said...

Hi

I trying to call a webservice hosted on Websphere 6.1 from a axis(1.3) based client. web service implements a oasis 2004 standard. while calling from a axis client i am getting following error

Did not understand "MustUnderstand" header(s)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstan=
dChecker.java:96)

Could you please help on this issue.

whereas when i see the soap response it does not show me any errors

Yaron Naveh (MVP) said...

Anonymous

please publish the soap response.

Anonymous said...

Hi,

Thanks a lot for your answer!
here's the soap response:





2010-12-29T10:49:41.620Z
2010-12-29T10:54:41.620Z





true

Yaron Naveh (MVP) said...

xml is not displayed well in these comments.

most probably the response contains a soap header with the must understand attribute.

this thread can be useful:

http://www.mail-archive.com/axis-user@ws.apache.org/msg10279.html

Anonymous said...

i finally figured it out: I needed a handler to process my soap header as the mustunderstand flag was on.

Thanks a lot