Lack of sent field from subclass in WCF - trying to gain polymorphism

后端 未结 2 601
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 12:06

First of all keep in mind, that I followed a very much stuff in google about this subject.
I am using WCF, to exposing some services. I have something like:

2条回答
  •  旧巷少年郎
    2020-12-22 12:40

    As I understand, you want to manually send correct XML to your service and make it recognize the Sub entity. In my comments to your question I mentioned approach with KnownTypes discovery, but it is solving another kind of problems.

    Your current C# code looks ok, but you are missing some type attributes in the XML. It should look like this:

    
       
       
          
             
                1
                2
             
          
       
    
    

    I just tested it and it worked fine in a WCF project created with VS 2015 and tested with SoapUI. Both sub and base values reached the test method and Sub entity was available inside of it.

    A similar question on StackOverflow with the same xsi:type solution also given here.

    If this does not help enough, I can upload the demo project somewhere on GitHub.

提交回复
热议问题