Consuming Protheus webservice in C# (array)

Asked

Viewed 1,316 times

1

I have two webservices developed in Protheus(TOTVS) that will be consumed in my C# application in VS2013(Windows form).

The first always returns a string and is working perfectly, the second returns an array and this I cannot consume at all.

It’s not a connection, because if I change the return of the second webservice to a string everything works normally, but as an array I can’t make Visual Studio 2013 understand at all.

It keeps returning me an error of "Cannot implicitly Convert type" and nothing solves.

Follow the published webservice method and the error generated:

WEBSERVICE REQUEST:

<?xml version="1.0" encoding="utf-8"?"
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
   <_CFILIAL>STRING</_CFILIAL>
</soap:Body>
</soap:Envelope>

WEBSERVICE RESPONSE

<?xml version="1.0" encoding="utf-8"?"
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
   <TARRAY>
      <TESTEARRAY>
         <_CCONTIGENCIA>STRING</_CCONTIGENCIA>
         <_CDIGITAL01>STRING</_CDIGITAL01>
         <_CDIGITAL02>STRING</_CDIGITAL02>
         <_CMATRICULA>STRING</_CMATRICULA>
         <_CNOME>STRING</_CNOME>
         <_CSITUACAO>STRING</_CSITUACAO>
      </TESTEARRAY>
      <TESTEARRAY>
         <_CCONTIGENCIA>STRING</_CCONTIGENCIA>
         <_CDIGITAL01>STRING</_CDIGITAL01>
         <_CDIGITAL02>STRING</_CDIGITAL02>
         <_CMATRICULA>STRING</_CMATRICULA>
         <_CNOME>STRING</_CNOME>
         <_CSITUACAO>STRING</_CSITUACAO>
      </TESTEARRAY>
   </TARRAY>
</soap:Body>
</soap:Envelope>

CONSUMING:

WS_FUNCSPONTO.FUNCSPONTO Recebe_Cadastro = new WS_FUNCSPONTO.FUNCSPONTO();
WS_FUNCSPONTO.TESTEARRAY qwert = new WS_FUNCSPONTO.TESTEARRAY();
qwert = Recebe_Cadastro.PEGAINFORM("00");

ERROR: Error 1 Cannot implicitly Convert type 'Relogio_ponto.WS_FUNCSPONTO.TESTEARRAY[]' to 'Relogio_ponto.WS_FUNCSPONTO.TESTEARRAY

1 answer

1

It’s a simple problem of cast. Switch to the next:

WS_FUNCSPONTO.TESTEARRAY[] qwert = new WS_FUNCSPONTO.TESTEARRAY[50];
  • Gypsy, thanks for the tip! I tried as you suggested and VS returned the following error on this line: Cannot implicitly Convert type 'Relogio_point.WS_FUNCSPONTO.TESTEARRAY' to 'Relogio_point.WS_FUNCSPONTO.TESTEARRAY[]'

  • How strange. Error reversed?

  • I managed to solve it! It was almost that! It turned out like this: WS_FUNCSPONTO.TESTEARRAY[] qwert = new WS_FUNCSPONTO.TESTEARRAY[50];

  • @Baltazar I’ll add your comment in reply.

Browser other questions tagged

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