none
Como configurar Binding, e endpoint address do app.conf manualmente via código c# RRS feed

  • Pergunta

  • Boa tarde amigos,

    Tenho uma aplicação de nota fiscal eletrônica, de manifestação de NF, e nela consumo web service do sefaz, para enviar dados e obter dados, sou de sp, fiz minha aplicação consumindo o web service de SP, porém a empresa que trabalho, em outras empresas em outros estados, ai invés de adicionar o web service normalmente gostaria de instanciar para bolar uma lógica para tal UF instanciar tal serviço , binding e cliente endpoint.

    Esse é o meu app.conf atual:

    <configuration>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="RecepcaoEventoSoap">
              <security mode="Transport">
                <transport clientCredentialType="Certificate" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="Certificate" algorithmSuite="Default" />
              </security>
            </binding>
            <binding name="NfeDownloadNFSoap">
              <security mode="Transport">
                <transport clientCredentialType="Certificate" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="Certificate" algorithmSuite="Default" />
              </security>
            </binding>
            <binding name="NFeConsultaDestSoap">
              <security mode="Transport">
                <transport clientCredentialType="Certificate" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="Certificate" algorithmSuite="Default" />
              </security>
            </binding>
          </basicHttpBinding>
          <customBinding>
            <binding name="NfeStatusServico2Soap12">
              <textMessageEncoding messageVersion="Soap12" />
              <httpsTransport authenticationScheme="Digest" requireClientCertificate="true" />
            </binding>
            <binding name="NfeRecepcao2Soap12">
              <textMessageEncoding messageVersion="Soap12" />
              <httpsTransport authenticationScheme="Digest" requireClientCertificate="true" />
            </binding>
            <binding name="RecepcaoEventoSoap12">
              <textMessageEncoding messageVersion="Soap12" />
              <httpsTransport />
            </binding>
          </customBinding>
        </bindings>
        <client>
          <endpoint address="https://www.nfe.fazenda.gov.br/NfeDownloadNF/NfeDownloadNF.asmx"
              binding="basicHttpBinding" bindingConfiguration="NfeDownloadNFSoap"
              contract="NfeDownload.NfeDownloadNFSoap" name="NfeDownloadNFSoap" />
          <endpoint address="https://www.nfe.fazenda.gov.br/RecepcaoEvento/RecepcaoEvento.asmx"
              binding="basicHttpBinding" bindingConfiguration="RecepcaoEventoSoap"
              contract="NfeRecepcao.RecepcaoEventoSoap" name="RecepcaoEventoSoap" />
          <endpoint address="https://homologacao.nfe.fazenda.sp.gov.br/ws/nfestatusservico2.asmx"
              binding="customBinding" bindingConfiguration="NfeStatusServico2Soap12"
              contract="NfeStatusServico.NfeStatusServico2Soap12" name="NfeStatusServico2Soap12" />
          <endpoint address="https://nfe.fazenda.sp.gov.br/nfeweb/services/nferecepcao2.asmx"
              binding="customBinding" bindingConfiguration="NfeRecepcao2Soap12"
              contract="NfeRecepcao2.NfeRecepcao2Soap12" name="NfeRecepcao2Soap12" />
          <endpoint address="https://nfe.fazenda.sp.gov.br/ws/recepcaoevento.asmx"
              binding="customBinding" bindingConfiguration="RecepcaoEventoSoap12"
              contract="NfeRecepcao3.RecepcaoEventoSoap12" name="RecepcaoEventoSoap12" />
          <endpoint address="https://www.nfe.fazenda.gov.br/NFeConsultaDest/NFeConsultaDest.asmx"
              binding="basicHttpBinding" bindingConfiguration="NFeConsultaDestSoap"
              contract="NFeConsultaDest.NFeConsultaDestSoap" name="NFeConsultaDestSoap" />
        </client>
      </system.serviceModel>
    </configuration>


    sexta-feira, 23 de janeiro de 2015 16:35

Respostas

Todas as Respostas