Wimdows.NET

Wim's .NET blog

Possible Bug : HttpPost and class name conflicts

A colleague and friend of mine run into some very odd web service behaviour on ASP.NET 1.1. Anyone who can shed some light on this, please leave a comment. I have pasted his exact text describing the problem below.

--
Included below is a minimal web-service implementation to recreate a problem
I've encountered in a web service that has methods returning classes with the
same local name (but in different namespaces).

If only the SoapHttp protocol is enabled in the web.config, everything works
as expected - with the different "Something" classes being serialized in to
different XML namespaces as defined by the ResponseNamespace property of the
SoapDocumentMethod attributes.

However - if HttpPost or HttpPostLocalhost are enabled (the latter being
enabled by default), and I browse to the asmx file in IE, I get this error :

Types NsProblem.B.Something and NsProblem.A.Something both use the XML type
name, Something, from namespace http://example/NsProblem/. Use XML attributes
to specify a unique XML name and/or namespace for the type.

If I un-comment both of the "XmlRoot" elements I get this error

The XML element named 'Something' from namespace 'http://example/NsProblem/'
references distinct types NsProblem.A.Something and NsProblem.B.Something.
Use XML attributes to specify another XML name or namespace for the element
or types.

Now for the really strange bit : leave one XmlRoot attribute commented, and
the other not, and it works!

When it is working, the example responses (on whatever.asmx?op=GetArrayA)
don't appear to tbe any difference!

(aside: I also tried setting the responses to be different using Xml
Serialization attributes, i.e. putting [return: XmlElement(... )] on the
methods, but like the SoapDocumentMethod attribute this only seemed to change
the response for the Soap method - making no difference to the HTTP POST
response)

Various workarounds are available
 - disable (remove) "HttpPost" and "HttpPostLocalhost" in web.config
 - Rename the classes (making the namespaces redundant)
but I would prefer to be able to keep the class names as they are, and keep
the HttpPostLocalhost enabled for testing / debugging purposes - and I
anticipate needing to support 3 or more classes with the same local-name
across different namespaces.

---- Minimal test case ----

<%@ WebService Language="c#" Class="NsProblem.XmlTestSvc" %>
using System;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Serialization;

namespace NsProblem.A
{
//    [XmlRoot(Namespace="AAAA")]
    public class Something { }
}

namespace NsProblem.B
{
//    [XmlRoot(Namespace="BBBB")]
    public class Something { }
}

namespace NsProblem
{
    [WebService(Description="Conflicting name problem example",
Namespace="http://example/NsProblem/")]
    public class XmlTestSvc : System.Web.Services.WebService
    {
        [WebMethod]
        [SoapDocumentMethod(ResponseNamespace="http://example/NsProblem/A")]
        public NsProblem.A.Something[] GetArrayA() { return null; }
       
        [WebMethod]
        [SoapDocumentMethod(ResponseNamespace="http://example/NsProblem/B")]
        public NsProblem.B.Something[] GetArrayB() { return null; }
    }
}

Posted: Oct 02 2005, 11:33 PM by Wim | with 26 comment(s)
Filed under: ,

Comments

ParksDoreen said:

If college students are willing their term paper format to be professionally done, they would have to use the prominent <a href="primeessays.com/index.php essay papers</a> service, which can be the best place to buy persuasive essay from.

# November 18, 2010 11:56 PM

Macready said:

Crawfish allergic to boiling water? lol. They really are and they have to so I can enjoy eating them.

# December 2, 2010 9:30 PM

do my essay said:

The buy essay service can use your hot release for a further gradual evolution, just because some people usually seek the custom research paper of supreme quality.

# December 4, 2010 6:47 AM

generic said:

Surprisingly! It is like you understand my mind! You seem to know so much about this, just like you wrote the book in it or something. I think that you can do with some pics to drive the content home a bit, but other than that, this is informative blog post. A good read. I’ll definitely revisit again.

# March 22, 2011 11:15 AM

generic viag`З said:

graet site. Keep doing

# March 22, 2011 3:43 PM

sildenafil said:

Do you have any more info on this?

# March 26, 2011 10:04 AM

discount gucci bags said:

hey buddy,this is one of the best posts that Ive ever seen; you may include some more ideas in the same theme. Im still waiting for some interesting thoughts from your side in your next post.<a href="www.discountguccibagssales.com/" title="discount gucci bags">discount gucci bags</a>

# July 26, 2011 11:00 PM

Cheap Timberland Boots said:

I am so thrilled for having found your site.<a href="www.cheap-timberlandbootsoutlet.com/" title="Cheap Timberland Boots">Cheap Timberland Boots</a>

# July 28, 2011 5:21 AM

designer handbags onsale said:

I read this informative article and I really enjoy reading it. I hope see more articles on this topic by you soon.<a href="www.cheap-designerhandbagsonsale.com/" title="designer handbags onsale">designer handbags onsale</a>

# August 1, 2011 3:51 AM

sac louis vuitton said:

Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.<a href="http://www.couue.com/" title="sac louis vuitton">sac louis vuitton</a>

# August 2, 2011 5:18 AM

Moncler Jackets said:

From all the posts in your blog, this is one of the interesting for me Just keep on work hard like you're doing!<a href="www.monclerjacketsca2u.com/" title="Moncler Jackets">Moncler Jackets</a>

# August 2, 2011 8:36 PM

goose down jackets said:

I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.<a href="www.greygoosejacketssale.com/" title="goose down jackets">goose down jackets</a>

# August 3, 2011 8:08 PM

Burberry outlet store said:

This is one of the best post I have ever read, I would love to read more in future. Keep up the good work. <a href="www.burberryoutletonline-store.com/" title="Burberry outlet store">Burberry outlet store</a>

# August 4, 2011 2:44 AM

designer bags said:

Intimately, the article is actually the sweetest on this deserving topic. I agree with your conclusions and will thirstily look forward to your upcoming updates. <a href="www.buy-designerbags.com/" title="designer bags">designer bags</a>

# August 4, 2011 8:19 PM

Timberland boots outlet said:

Very nice post. I really enjoy the reading. I  come here from the google while searching for some good article.Thanks <a href="www.cheap-timberlandbootsoutlet.com/" title="Timberland boots outlet">Timberland boots outlet</a>

# August 6, 2011 5:46 AM

Timberland boots outlet said:

Very nice post. I really enjoy the reading. I  come here from the google while searching for some good article.Thanks <a href="www.cheap-timberlandbootsoutlet.com/" title="Timberland boots outlet">Timberland boots outlet</a>

# August 8, 2011 5:24 AM

wholesale jerseys said:

Just want to say your article is brilliant. The clarity in your post is simply impressive and i can assume you are an expert on this subject.

# August 10, 2011 10:41 PM

cheap ed hardy outlet said:

Enjoyed quickly looking over your blog and will bookmark for future use, thanks!

# August 12, 2011 4:28 AM

Birkenstock sandals said:

I wanted to thanks for this great read!! I undoubtedly loved every little little bit of it.<a href="www.birkenstocksandalscheapsale.com/" title="Birkenstock sandals">Birkenstock sandals</a>

# August 13, 2011 4:32 AM

cheap north face jackets said:

I continue to read blogs like this, because I am trying to better my ability to write great content, this is an awesome example.[url=www.cheapnorthfaceoutlets.com]cheap north face jackets[/url]

# August 16, 2011 4:33 AM

cheap herve leger dress said:

I always enjoy your posts, your real, and some times funny as well. keep it up!<a href="www.cheapherveleger-sale.com/" title="cheap herve leger dress">cheap herve leger dress</a>

# August 16, 2011 9:37 PM

mens leather belts said:

Excellent post ! You make some brilliant points very nice realization. keep it up!<a href="www.mens-leatherbelts.com/" title="mens leather belts">mens leather belts</a>

# August 17, 2011 2:46 AM

Ray Ban sunglasses uk said:

Maintain up the beneficial function mate. This website article exhibits how properly you comprehend and know this subject.<a href="www.raybansunglassesinuk.com/" title="Ray Ban sunglasses uk">Ray Ban sunglasses uk</a>

# August 19, 2011 10:42 PM

cheap Prada handbags said:

I read this informative article and I really enjoy reading it. I hope see more articles on this topic by you soon.

# September 12, 2011 10:39 PM

Ralph Lauren outlet said:

Thanks for sharing your thoughts with us.I enjoyed well while reading your article.<a href="www.ralphlaurenoutletstore.net/" title="Ralph Lauren outlet">Ralph Lauren outlet</a>

# September 16, 2011 4:50 AM

Buy Microsoft Office software online said:

JoZb1F I read and feel at home. Thanks the creators for a good resource..!!

# December 28, 2011 4:33 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)