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

Asked

Viewed 1,024 times

9

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

Sand I type 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.

Mas, if I import the WSDL to consume the services, 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, an object is generated Cabecalho for each message (as well as many others who 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 it is also not possible to use the class objects generated by XSD.

The point is:

  1. 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...)

  2. There are other ways to implement these integrations when provided xsd/wsdl?

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


Obs. To generate the classes by schema, I use xsd.exe. I still have problems because some properties should be deleted if null and are not, so the xml generated with these classes is not validated by the schema itself that originated the classes. This problem I’m getting right creating properties:

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

All the documentation provided by the NSA

Archive with XSD and WSDL

1 answer

1

Hello, Rovann, to facilitate in future uses, I have created a Web App on Github already with the WSDL files imported into the application, ready for use.

Everyone wants the fish, but few teach how to fish. Follow the step-by-step fishing.

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

Passo 1

To import WSDL files from TISS, you will need to access advanced options as per:

Passo 2

Repeat steps 1 and 2 until all WSDL files have been embedded into the application.

Configurado

I hope it helps.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.