2016-03-17 123 views
2

我很難弄清楚什麼是goint錯誤。Delphi HTTPRIO:簽署證書的肥皂請求後發生錯誤

我得到這個消息:

Debugger Exception Notification 
    Project Project9.exe raised exception class ERemotableException with message 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.ArgumentNullException: Value cannot be null. 
Parameter name: node 
at System.Xml.XmlNodeReader..ctor(XmlNode node) 
at Serpro.Sped.eFinanceira.WsInternet.WsRecepcao.ReceberLoteEvento(XmlDocument loteEventos) 
--- End of inner exception stack trace ---'. 
Break Continue Help 

匯入我WSDL這是我的幹訓click事件之後。

procedure TForm7.Button1Click(Sender: TObject); 
var 
vWsRecepcaoSoap : WsRecepcaoSoap; 
vXmlData : loteEventos; 
vHTTPRIO : THTTPRIO; 
begin 
vHTTPRIO := THTTPRIO.Create(Nil); 
vHTTPRIO.WSDLLocation := 'http://www1.receita.fazenda.gov.br/sistemas/e-financeira/documentos/doc-download/WsRecepcao.wsdl'; 
vHTTPRIO.Service := 'WsRecepcao'; 
vHTTPRIO.Port := 'WsRecepcaoSoap12'; 
vHTTPRIO.HTTPWebNode.OnBeforePost := HTTPRIO1HTTPWebNode1BeforePost; 
//vHTTPRIO.OnBeforeExecute := HTTPRIO1BeforeExecute; 
vWsRecepcaoSoap := vHTTPRIO as WsRecepcaoSoap; 
vXmlData := TXMLData.Create; 
vXmlData.LoadFromXML(
//'<?xml version="1.0" encoding="UTF-8"?> '+ 
'<eFinanceira xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '+ 
'xmlns="http://www.eFinanceira.gov.br/schemas/envioLoteEventos/v1_0_1">'+ 
' <loteEventos>'+ 
' <evento id="ID0">'+ 
' <eFinanceira xmlns="http://www.eFinanceira.gov.br/schemas/evtAberturaeFinanceira/v1_0_0">'+ 
' <evtCadDeclarante id="ID00000001762">'+ 
' <ideEvento>'+ 
' <indRetificacao>1</indRetificacao>'+ 
' <tpAmb>2</tpAmb>'+ 
' <aplicEmi>2</aplicEmi>'+ 
' <verAplic>00000000000000000707</verAplic>'+ 
' </ideEvento>'+ 
' <ideDeclarante>'+ 
' <cnpjDeclarante>02475222000196</cnpjDeclarante>'+ 
' </ideDeclarante>'+ 
' <infoCadastro>'+ 
' <nome>CECM SERV ESTAT ADM DIRETA EST E SANTO</nome>'+ 
' <enderecoLivre>AV JOAO BATISTA PARRA N 673 EDF ENSEADA TOWER LJ 1 PRAIA DO SUA</enderecoLivre>'+ 
' <municipio>3205309</municipio>'+ 
' <UF>ES</UF>'+ 
' <Pais>BR</Pais>'+ 
' <paisResidencia>BR</paisResidencia>'+ 
' </infoCadastro>'+ 
' </evtCadDeclarante>'+ 
' <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">'+ 
' <SignedInfo>'+ 
' <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>'+ 
' <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>'+ 
' <Reference URI="#ID00000001762">'+ 
' <Transforms>'+ 
' <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>'+ 
' <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>'+ 
' </Transforms>'+ 
' <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>'+ 
' <DigestValue>G8kSjLVludtkatDuCm2rLszM7D4=</DigestValue>'+ 
' </Reference>'+ 
' </SignedInfo>'+ 
' <SignatureValue>f7OmvLKjuuRQiX+6tgqBYxB5zBFgxjXMyXOqZkWtLhgW2lP/ZzM7xrnt9HZFBSetIhJNGuPhKysZzf4hZClW1YSEfi2WECb3CNzBCfjzeOA2fEJ/FJXdYdDsAvtzjTbt'+ 
'E+MqrJW/u9sGNJHJDTtVfdjPwt3Y9NUJJ0SADvDtXPiow71rcpAeg3fQD3IIFlPLyz0WbGiUyzDcsl3pb7L7AYilj5Pm5utV0COq8A0jwnMylKolGHScXgJaPW3U9qH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dLGbO9HkaZ3nziwOTKHzq32G0MsQ47g4aoeOt9p9SNZhcUoSXESPgCco'+ 
'uJSLW2H2SYp7bBBB1hDivWqqhwgDXY+kGkleKgjWrE4KdhXQXzD0hj9OubG/huOBUyRaD3kAGF2yTxqUS4vl/oRicpO3NyPa0f3ScGkKtLsAJUAfnfv9p5JUEpVR5sFf7RoGXvv6zDoZnG7QKxuUR'+ 
'L+x5/ZV2k5dmNSkcmyCwKKnguytRA/S/UZ1NJ3+G3M4g+nNMuofMlFLYPtGGLWQWEY9i32wARLjo6fwcD26NxRxVRYkUOmMe8GSc7gmfqNSC/+FMqMV12EJdvgui6gytLVaXfC1oAjXwkb0e3pQT7'+ 
'u0+jZsnfAexAvOCNEfe6Jx9ANOF7KrvOr5Tp33l2lPcGD3PQRMsySUCHb95mu9lZ/lqzEKJjwXJ4z2KCCPQ6Su8FKTgUoYTl2BnTJBBPDw06nLBwqB2EiFWnPr+NF5HEuLDcGTysgoFcll4fPJu3y'+ 
'2OMeq6OGR3xOhK2FEJx9efYZ6KKtGVrR4l6IieDK9joskSRYzU+ZERjvHD8dWm1U9+QXjQ=</X509Certificate></X509Data></KeyInfo></Signature>'+ 
' </eFinanceira>'+ 
' </evento>'+ 
' </loteEventos></eFinanceira>'); 

vXmlData := vWsRecepcaoSoap.ReceberLoteEvento(vXmlData); 
Memo2.text := vXmlData.XMLNode.XML; 

end; 

procedure TForm7.HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp; 
Data: Pointer); 
var 
    Store  : IStore; 
    Certs  : ICertificates; 
    Cert   : ICertificate2; 
    CertContext : ICertContext; 
    PCertContext : PCCERT_CONTEXT; 
    V   : OleVariant; 
    vCertsLista  : ICertificates2; 
begin 
    (* 
    thumbprint of the certificate to use. Look at CAPICOM docs to see 
    how to find certs using other Id's 
    *) 
(* 
    thumbprint of the certificate to use. Look at CAPICOM docs to see 
    how to find certs using other Id's 
    *) 
    V := 'BC50E0E8CA750D6F7524EC58B3071E9FCB4C8920'; 

    (* create Certificate store object *) 
    Store := CoStore.Create; 

    (* open the My Store containing certs with private keys *) 
    Store.Open(CAPICOM_CURRENT_USER_STORE, 'MY', CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED); 

    (* find the certificate with the given thumbprint *) 
    vCertsLista  := Store.Certificates as ICertificates2; 

    Certs := vCertsLista.Find(CAPICOM_CERTIFICATE_FIND_SHA1_HASH, V, False); 

// Certs := Store.Certificates.Find(CAPICOM_CERTIFICATE_FIND_SHA1_HASH, V, False); 


    (* any certificates found? *) 
    if Certs.Count > 0 then 
    begin 
    (* get the certificate context *) 
    Cert := IInterface(Certs.Item[ 1 ]) as ICertificate2; 
    CertContext := Cert as ICertContext; 
    CertContext.Get_CertContext(Integer(PCertContext)); 

    (* set the certificate to use for the SSL connection *) 
    if InternetSetOption(Data, INTERNET_OPTION_CLIENT_CERT_CONTEXT, 
     PCertContext, Sizeof(CERT_CONTEXT)) = False then 
    begin 
     raise Exception.Create('Erro ao configurar certificado para conexão SSL.'); 
    end; 
    end; 

end; 

請任何人都可以幫我嗎? 非常感謝!

請求:

<?xml version="1.0"?> 
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
     <SOAP-ENV:Body> 
     <schema xmlns="http://www.w3.org/2001/XMLSchema"> 
      <eFinanceira xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.eFinanceira.gov.br/schemas/envioLoteEventos/v1_0_1"> 
      <loteEventos> 
       <evento id="ID0"> 
       <eFinanceira xmlns="http://www.eFinanceira.gov.br/schemas/evtAberturaeFinanceira/v1_0_0"> 
        <evtCadDeclarante id="ID00000001762"> 
        <ideEvento> 
         <indRetificacao>1</indRetificacao> 
         <tpAmb>2</tpAmb> 
         <aplicEmi>2</aplicEmi> 
         <verAplic>00000000000000000707</verAplic> 
        </ideEvento> 
        <ideDeclarante> 
         <cnpjDeclarante>02475222000196</cnpjDeclarante> 
        </ideDeclarante> 
        <infoCadastro> 
         <nome>CECM SERV ESTAT ADM DIRETA EST E SANTO</nome> 
         <enderecoLivre>AV JOAO BATISTA PARRA N 673 EDF ENSEADA TOWER LJ 1 PRAIA DO SUA</enderecoLivre> 
         <municipio>3205309</municipio> 
         <UF>ES</UF> 
         <Pais>BR</Pais> 
         <paisResidencia>BR</paisResidencia> 
        </infoCadastro> 
        </evtCadDeclarante> 
        <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> 
        <SignedInfo> 
         <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> 
         <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> 
         <Reference URI="#ID00000001762"> 
         <Transforms> 
          <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> 
          <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> 
         </Transforms> 
         <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
         <DigestValue>G8kSjLVludtkatDuCm2rLszM7D4=</DigestValue> 
         </Reference> 
        </SignedInfo> 
        <SignatureValue>f7OmvLKjuuRQiX+6tgqBYxB5zBFgxjXMyXOqZkWtLhgW2lP/ZzM7xrnt9HZFBSetIhJNGuPhKysZzf4hZClW1YSEfi2WECb3CNzBCfjzeOA2fEJ/FJXdYdDsAvtzjTbtE+MqrJW/u9sGNJHJDTtVfdjPwt3Y9NUJJ0SADvDtXPiow71rcpAeg3fQD3IIFlPLyz0WbGiUyzDcsl3pb7L7AYilj5Pm5utV0COq8A0jwnMylKolGHScXgJaPW3U9qHw9KDeaGP0NfgEYyYTk/C8TNSZXb5AKj2sFr9rfLRuTOqEJHjKvlYmWsGUCTwEVkkNakTYbuNFYsXB++nVVaoD7Q==</SignatureValue> 
        <KeyInfo> 
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vv6zDoZnG7QKxuURL+x5/ZV2k5dmNSkcmyCwKKnguytRA/S/UZ1NJ3+G3M4g+nNMuofMlFLYPtGGLWQWEY9i32wARLjo6fwcD26NxRxVRYkUOmMe8GSc7gmfqNSC/+FMqMV12EJdvgui6gytLVaXfC1oAjXwkb0e3pQT7u0+jZsnfAexAvOCNEfe6Jx9ANOF7KrvOr5Tp33l2lPcGD3PQRMsySUCHb95mu9lZ/lqzEKJjwXJ4z2KCCPQ6Su8FKTgUoYTl2BnTJBBPDw06nLBwqB2EiFWnPr+NF5HEuLDcGTysgoFcll4fPJu3y2OMeq6OGR3xOhK2FEJx9efYZ6KKtGVrR4l6IieDK9joskSRYzU+ZERjvHD8dWm1U9+QXjQ=</X509Certificate> 
         </X509Data> 
        </KeyInfo> 
        </Signature> 
       </eFinanceira> 
       </evento> 
      </loteEventos> 
      </eFinanceira> 
     </schema> 
     </SOAP-ENV:Body> 
    </SOAP-ENV:Envelope> 
+0

哪一行代碼呢拋出異常? – whosrdaddy

+0

它確實通過了之前發佈的事件...並要求輸入密碼..在執行我的soap xml之前它也可以vXmlData:= vWsRecepcaoSoap.ReceberLoteEvento(vXmlData); – Marisco

+0

發佈了肥皂請求。 – Marisco

回答

0

的.NET服務器傳回錯誤:「服務器無法處理請求」 所以,你必須聯繫該服務的業主

+0

那麼,你認爲everythig對編碼和請求是否合適?有沒有給所有者發郵件等待回覆。 – Marisco

+0

我已經嘗試了與c#相同的事情,並獲得更多詳細信息的錯誤,我認爲這絕對是一個服務器問題:System.Web.Services.Protocols.SoapException:服務器無法處理請求。 ---> System.NullReferenceException:未將對象引用設置爲對象的實例。在Serpro.Sped.eFinanceira.WsInternet.Util.MontaXMLRetorno(XElement xelement)Serpro.Sped.eFinanceira.WsInternet.WsRecepcao.ReceberLoteEvento(XmlDocument loteEventos) – Marisco