Generate classes with XSD or import WSDL [ANS / TISS]

9

ANS provides the .XSD , and .WSDL files for TISS implementation.

S and I generate the code by .XSD, I have the classes structured correctly. Example:

namespace TissV3
{
    class Cabecalho
    {
       ...
    }

    class MensagemA
    {
       public Cabecalho cabecalhoTransacao {get;set;}
    }

    class MensagemB
    {
       public Cabecalho cabecalhoTransacao {get;set;}
    }
}

So the header of message A is of the same type as the header of message B.

M , if I import the WSDL to consume the services, it is generated as follows:

namespace MensagemAv3
{
    class Cabecalho
    {
       ...
    }

    class MensagemA
    {
       public Cabecalho cabecalhoTransacao {get;set;}
    }

    class ClientSoap
    {
        ExecutarSolicitacao(MensagemA obj);
    }
}

namespace MensagemBv3
{
    class Cabecalho
    {
       ...
    }

    class MensagemB
    {
       public Cabecalho cabecalhoTransacao {get;set;}
    }

    class ClientSoap
    {
        ExecutarSolicitacao(MensagemB obj);
    }
}

So, a Cabecalho object is generated for each message (as well as many others that make up the message). In this case, it is not possible to reuse the codes, I would have to generate each header of each message ... And also it is not possible to use the objects of classes generated by XSD.

The question is:

  • I'm using the schemas correctly? (and I'll have to change the code in hand, or leave it with that bunch of duplicate classes ...)

  • There are other ways to implement these integrations when you provide xsd / wsdl?

  • It is possible that the problem is in the structure developed, in this case, by ANS?

  •   

    obs. To generate the classes by schema, I use xsd.exe. I still have problems because some properties should be suppressed if they are null and void, so the xml generated with these classes is not validated by the schema itself that originated the classes. This problem I hit by creating properties:

    public bool [foo]Specified 
    {
        get 
        { 
            return [foo] != null; 
        } 
        set { return; } 
    }
    

    All documentation provided by ANS

    Archive with the XSD and WSDL

        
    asked by anonymous 11.06.2018 / 16:29

    1 answer

    1

    Hello, Rovann, for ease of use in the future, I created a Web App on GitHub already with the WSDL files imported into the application, ready for use.

    Everyone wants fish, but few teach fishing. Follow the fishery's step-by-step instructions.

    To embed the WSDL files, you need to right-click on the solution and select Add -> Service Reference, as follows:

    ToimporttheTISSWSDLfiles,youwillneedtoaccesstheadvancedoptionsasfollows:

    Repeatsteps1and2untilallWSDLfileshavebeenaddedtotheapplication.

    I hope it helps.

        
    25.10.2018 / 19:31