开发者

Soap - Element doesn't have xsi:nil as a property, but deserializing doesn't make the object not null

I'm a total noob when it comes to XML and SOAP messages. ...Here's the SOAP message.

<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <CR>
            <Username xmlns="<Hidden>">mtas</Username>
            <Password xmlns="<Hidden>">password</Password>
            <id xmlns="<Hidden>">
                70dad12b-bb50-402d-8b34-
                fe2d4c0c283d
            </id>
            <Data xmlns="<Hidden>">
                <Data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns="<Hidden>">
        开发者_高级运维            <CS>
                        <CSCallbackRequest xmlns="">
                            <CDS xsi:nil="true" xmlns="<Hidden>"/>
                            <CDRP xmlns="<Hidden>"/>
                            <UDI xsi:nil="true"
                            xmlns="<Hidden>"/>
                        </CSCallbackRequest>
                    </CS>
                    <Fault xsi:nil="true" />
                    <Comment xsi:nil="true"/>
                </Data>
            </Data>
        </CR>
    </s:Body>
</s:Envelope>

We generated the classes with the xsd.exe tool that gave us classes to deserialize to. This .xsd file was provided by the company we are receiving the SOAP messages from.

Here is the issue. When we get this type of response back from the company, we are looking within CSCallbackRequest for those three elements inside, the CDS, CDRP, and UDI. We are attempting to determine which type of Callback we're receiving. My initial assumption was when we use an XMLSerializer with type (Generated Class Type), the element within CSCallbackRequest that does not have the xsi:nil=true would allow the object within the Generated Class Type object would NOT be null. But this isn't the case. How do I check if a property with the doesn't have the xsi:nil proprerty after deserializing?


Actually, I figured out the issue. The SOAP message I put here is actually an example from the company's documentation. I was attempting to use this as a mock up for a message that we would receive. After comparing the generated class files from the XSD, I noticed that the <CS> was not actually defined in the files. When it was deserializing, it wouldn't find that element, therefore populate nothing, since we started deserializing from the <Data> element and beyond. I checked the other examples in the documentation and those did not have this extra <CS> element. Removing of that element fixed this whole issue. I've notified the company of their error in documentation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜