Question

I have an xml how can i structure the class so that when i serialize it, it looks like this.

<Security xmlns="http://docs.oasis-open.org/x/xxxxx.xsd"  xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
    <saml:Assertion ID="xxxxx" IssueInstant="xxxxxxx" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
        <saml:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified">MyApp</saml:Issuer>
        <saml:Subject>
            <saml:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:unspecified">MyApp</saml:NameID>
        </saml:Subject>
        <saml:AttributeStatement>
            <saml:Attribute Name="UserID" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
                <saml:AttributeValue>TestUserID</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="UserFirstName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
                <saml:AttributeValue>TestUserFirstName</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="UserLastName" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
                <saml:AttributeValue>TestUserLastName</saml:AttributeValue>
            </saml:Attribute>
            <saml:Attribute Name="ReasonForSearch" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
                <saml:AttributeValue>ReasonForSearch</saml:AttributeValue>
            </saml:Attribute>
        </saml:AttributeStatement>
    </saml:Assertion>
</Security>
Was it helpful?

Solution

Use the xsd.exe to first generate an XSD and then use the same exe to generate class files. More info - http://msdn.microsoft.com/en-us/library/x6c1kb0s.aspx.

Saved your xml as security.xml on my system and ran the following commands in visual studio command prompt:

xsd Security.xml

The step above generated two xsd files which can be used to generate class.

xsd Security.xsd Security_app1.xsd /classes
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top