Wednesday, September 01, 2004

SoapInclude & XmlInclude

Yesterday, I coded a webservice that needed to return an array of objects that derived from a common base (abstract) class. When I tried to access the webservice, I had the following message:

The type XXX.YYY was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.


I thought: "Doh! Sure! ASP.NET needs to know about all the concrete classes, not only about the base class to be able to generate a proper WSDL, so a proper proxy client can be generated. Simple! Just add a SoapInclude(typeof()) attribute for each of the concrete classes and there we go!".
And so I did it. It didn't work.
I copy & pasted the MSDN sample for the SoapInclude attribute. It didn't work.
I tried it on a machine without SP1. It didn't work.
I tried to add the SoapInclude() attribute on the base class. It didn't work.
On a desperate try, I remove all the SoapInclude() attributes and used XmlInclude() attributes (remember the error message)? Yeah! It worked!
So, I leave this for anyone who may have the same problem and find me through Google or who can explain me why the SoapInclude() attribute didn't work.

Comments:
I had the same problem. I did as you suggested and used XmlInclude and it also worked for me. I wish I could explain it... But just as long as it works!

Thanks for the tip.
 
Hey, I just came across that error yesterday.. and we tried soapInclude... which seemed to do nothing.. and then we tried xmlinclude, and that generated an error that it couldn't find z309jfz3fz.dll (each time we accessed the webservice, "z309jfz3fz" became a new apparently random string of numbers and letters. huh. I wish it "just worked". :}
 
.

Free Anonymous Proxies

69.25.27.209:80
80.224.16.222:80
134.39.27.36:80
213.26.185.228:80
203.131.80.158:80
203.144.216.211
211.101.6.3:8080

More Free Proxies: Go to http://jeepee.biz/infopage, and get them at "Page1", "Page2" and "Page3"

Good luck!

jeepee.biz
 
I had the same problem! soapInclude didn't work, but it worked with xmlInclude!
thanks for the hint! ;-)
 
Was trying SoapInclude, didn't work.. XmlInclude worked fine.

Thanks! :)

-ben
 
Hey, thanks! You saved me a lot of trouble :)))
 
Hey, thanks! You saved me a lot of trouble :)))
 
Hey, thanks! You saved me a lot of trouble :)))
 
Oops... Sorry :/ Thought I made a mistake entering turing numbers, and published my comment too much times. There could be big & visible "Your comment was added!" sign...
 
hi
could you tell me how exactly you used Xmlinclude.
i'll also try it out.
been stuck with this thing for so long
 
xmlinclude worked for me too. soapinclude didnt.
 
same to me, thanks
 
I'm going to assume you were trying this from a web browser - in which case soapinclude would be ignored as it would be looking to serialize to xml and not a soap message. If you requested the data via a soap client i expect it would have worked.
 
SoapInclude will only work if its used on RPC/Encoded services. ASP.NET uses document encoding, so XMLInclude is more appropriate.

http://vascooliveira.com/Blog/archive/2008/06/17/xmlinclude-and-soapinclude-explained.aspx
 
We always Wow Power Leveling and world of warcraft gold
 
Wicked - this just helped me. *Blessings*
 
hey buddy,this is one of the best posts that I�ve ever seen; you may include some more ideas in the same theme. I�m still waiting for some interesting thoughts from your side in your next post.
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?