Lucky Man
Lucky Man

Reputation: 1518

How to make Gsoap XML parsing read correct elements from response messages and ignore wrong/corrupted ones?

According to onvif documentaion https://www.onvif.org/ver10/schema/onvif.xsd ImagingSettings20 type has a tt:FocusConfiguration20 element

    <xs:complexType name="ImagingSettings20">
        <xs:annotation>
            <xs:documentation>Type describing the ImagingSettings of a VideoSource. The supported options and ranges can be obtained via the GetOptions command.</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            ...
            <xs:element name="Focus" type="tt:FocusConfiguration20" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Focus configuration.</xs:documentation>
                </xs:annotation>
            </xs:element>

            ...
        </xs:sequence>
        <xs:anyAttribute processContents="lax"/>
    </xs:complexType>

Imaging wsdl https://www.onvif.org/ver20/imaging/wsdl/imaging.wsdl

However one of the ONVIF cameras sends the following GetImagingSettingsResponse:

        <timg:GetImagingSettingsResponse>
            <timg:ImagingSettings>
                <tt:Brightness>0</tt:Brightness>
                <tt:ColorSaturation>0</tt:ColorSaturation>
                <tt:Contrast>0</tt:Contrast>
                <tt:Sharpness>50</tt:Sharpness>
                <tt:Focus>
                    <tt:AutoFocusModes>AUTO</tt:AutoFocusModes>
                    <tt:AutoFocusModes>MANUAL</tt:AutoFocusModes>
                    <tt:DefaultSpeed>
                        <tt:Min>1</tt:Min>
                        <tt:Max>1</tt:Max>
                    </tt:DefaultSpeed>
                    <tt:NearLimit>
                        <tt:Min>10</tt:Min>
                        <tt:Max>2000</tt:Max>
                    </tt:NearLimit>
                    <tt:FarLimit>
                        <tt:Min>0</tt:Min>
                        <tt:Max>0</tt:Max>
                    </tt:FarLimit>
                </tt:Focus>
            </timg:ImagingSettings>
        </timg:GetImagingSettingsResponse>

So instead of tt:FocusConfiguration20 it sends tt:FocusOptions20 in response Which is completely wrong GSOAP generated C++ code fails to parse such response and stops parsing right after it finds the wrong element tt:Focus

However I would like to have a possibility to parse at least the correct fields from the response message:

                <tt:Brightness>0</tt:Brightness>
                <tt:ColorSaturation>0</tt:ColorSaturation>
                <tt:Contrast>0</tt:Contrast>
                <tt:Sharpness>50</tt:Sharpness>

And just ignore the failed element tt:Focus (only in case it has tt:FocusOptions20 type insead of tt:FocusConfiguration20 or wrong/corrupted) If tt:Focus is correct, I want to parse it

Could someone suggest the best way to do that? Thanks in advance Any help would be greatly appreciated

Upvotes: 0

Views: 58

Answers (0)

Related Questions