开发者

.NET 2.0 Web service creating new objects when null supplied via soap

I have an ASP.NET 2.0 web service and am using it in (among other things) an Adobe Flex application. I have a strange issue where if I send an object to the web service using soap with some fields that are null the webservice is actually creating new objects on the other end (and not putting any data in them).

The XML being sent looks like this:

 <tns:Item>
            <tns:Id>-1</tns:Id>
            <tns:SomeField>21114</tns:SomeField>
            <tns:SomeFieldThatShouldBeNull xsi:nil="true"/>
            <tns:SomeFieldThatShouldBeNull2 xsi:nil="true"/>
</tns:Item>

In 开发者_JS百科this example SomeFieldThatShouldBeNull and SomeFieldThatShouldBeNull2 are being created as new objects by the webservice. It is vital for the application that does not happen. What could be causing this?

Google, MSDN and the ASP.NET forums have not come up trumps so far.


Fixed by random prodding. It seems that I have to put the following attribute on the field in the .NET code to get it to treat a field with an xsi:nil="true" attribute as a null value:

[System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜