How to reference eSocial webservices by Visual Studio?

4

I've already followed the instructions of this question li, reli, and have re-read the Pedro Gaspar tutorial several times. And I can not reference the eSocial webservices through Visual Studio. What I've done so far was:

  • I installed the certificate chains, both on 1/15/2014 and 06/02/2017 in the correct sequence.
  • I installed the chains by putting all the certificates in the Local Machine Root repository
  • I installed the chains by placing only the Brazilian Root Certification Authority v5 in the Root repository and the rest in the broker repository.
  • I installed the certificate (valid, not expired and with the correct password) from my client in the Personal repository (On the local Machine and the Current User)

I can access the webservices addresses through the browser and the padlock turns green. When I try to add service reference through visual studio the following occurs:

Whendoinga"Web Reference", the following happens:

SeethatitaccessestheWS(sinceinthebrowseritalsoaccesses),buttheforbiddenstillappears.

ItriedtodoitthroughSVCUTIL.EXEandtheresultwasasfollows:

C:\WINDOWS\system32>svcutilhttps://webservices.producaorestrita.esocial.gov.br/servicos/empregador/consultarloteeventos/WsConsultarLoteEventos.svc?singleWsdlMicrosoft(R)ServiceModelMetadataTool[Microsoft(R)Windows(R)CommunicationFoundation,Version4.6.1055.0]Copyright(c)MicrosoftCorporation.Allrightsreserved.Attemptingtodownloadmetadatafrom'https://webservices.producaorestrita.esocial.gov.br/servicos/empregador/consultarloteeventos/WsConsultarLoteEventos.svc?singleWsdl'usingWS-MetadataExchangeorDISCO.Microsoft(R)ServiceModelMetadataTool[Microsoft(R)Windows(R)CommunicationFoundation,Version4.6.1055.0]Copyright(c)MicrosoftCorporation.Allrightsreserved.Error:CannotobtainMetadatafromhttps://webservices.producaorestrita.esocial.gov.br/servicos/empregador/consultarloteeventos/WsConsultarLoteEventos.svc?singleWsdlIfthisisaWindows(R)CommunicationFoundationservicetowhichyouhaveaccess,pleasecheckthatyouhaveenabledmetadatapublishingatthespecifiedaddress.Forhelpenablingmetadatapublishing,pleaserefertotheMSDNdocumentationathttp://go.microsoft.com/fwlink/?LinkId=65455.WS-MetadataExchangeErrorURI:https://webservices.producaorestrita.esocial.gov.br/servicos/empregador/consultarloteeventos/WsConsultarLoteEventos.svc?singleWsdlMetadatacontainsareferencethatcannotberesolved:'https://webservices.producaorestrita.esocial.gov.br/servicos/empregador/consultarloteeventos/WsConsultarLoteEventos.svc?singleWsdl'.TheHTTPrequestwasforbiddenwithclientauthenticationscheme'Anonymous'.Theremoteserverreturnedanerror:(403)Forbidden.HTTPGETErrorURI:https://webservices.producaorestrita.esocial.gov.br/servicos/empregador/consultarloteeventos/WsConsultarLoteEventos.svc?singleWsdlTherewasanerrordownloading'https://webservices.producaorestrita.esocial.gov.br/servicos/empregador/consultarloteeventos/WsConsultarLoteEventos.svc?singleWsdl'.TherequestfailedwithHTTPstatus403:Forbidden.Ifyouwouldlikemorehelp,type"svcutil /?"

C:\WINDOWS\system32>

I noticed the messages Error: Cannot obtain Metadata... , Metadata contains a reference that cannot be resolved and The HTTP request was forbidden with client authentication scheme 'Anonymous'

My chances are exhausted, I do not know what to test. Anyone have a suggestion?

    
asked by anonymous 15.06.2018 / 20:30

2 answers

3

Ewerton, the easiest way is to access the URL in the browser:

  

link

Right-click the page, click Save as ... and save a file with .wsdl extension on the local machine, and then use this WSDL file ( Web Services Description Language ) to add the reference to the service in Visual Studio. I think I did that at the time.

The other way (which I learned now, hehe), for you to be able to add the service using the URL directly is a bit trickier because Visual Studio has to know the certificate that should be used to access a particular address. / p>

For this you must access the Windows Control Panel and do this path (my Windows is in English, so I do not know what the Portuguese names are): Control Panel > User Accounts > Credential Manager > Manage Windows Credentials in the Certificate-Based Credentials section you click on the Add a credential-based credential link.

You then enter the webservices.producaorestrita.esocial.gov.br domain in the Internet or network address field, and click the Select certificate button.

I've learned this tip now with this SO EN answer:

  

link

If you have Visual Studio open, exit and log in again. After that Visual Studio must recognize which certificate to use to access the eSocial service (in the Restricted Production environment).

    
15.06.2018 / 22:03
1

In the Technical Documentation available, you have the "#

15.06.2018 / 22:45