Autor Zpráva
pajadvorak
Profil
Marně si lámu hlavu s tím jak podepsat XML včetně hlavičky pro EET. Prosím o radu. Již se v tom nějak motám...

Momentálně mi to vrací XML bez hlavičky.
Děkuji.



Odkaz na kód:
pastebin.com/pbfiBtBD



require 'wse/soap-wsse.php';

define('PRIVATE_KEY', 'certifikaty/privat_key.pem');
define('CERT_FILE', 'certifikaty/certifikat.pem');
//require 'wse-php-master/soap-wsse.php';
//define('PRIVATE_KEY', 'F:\\php\\EasyPHP-Devserver-16.1\\eds-www\\eet\\other\\01000004.p12');
//define('CERT_FILE', 'F:\\php\\EasyPHP-Devserver-16.1\\eds-www\\eet\\other\\ca.cer.pem');
 
class MySoap extends SoapClient {
 
    public function __doRequest($request, $location, $saction, $version, $one_way = null) {
        $doc = new DOMDocument('1.0');
        $doc->loadXML($request);
 
        $objWSSE = new WSSESoap($doc);
 
        /* add Timestamp with no expiration timestamp */
        //$objWSSE->addTimestamp();
 
        /* create new XMLSec Key using RSA SHA-1 and type is private key */
        $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type' => 'private'));
 
        $objKey->passphrase = "eet";
       
        /* load the private key from file - last arg is bool if key in file (true) or is string (FALSE) */
        $objKey->loadKey(PRIVATE_KEY, true);
 
        /* Sign the message - also signs appropraite WS-Security items */
        $objWSSE->signSoapDoc($objKey, array("algorithm" => XMLSecurityDSig::SHA256));
                  
        /* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
        $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
        $objWSSE->attachTokentoSig($token);
        return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version, $one_way);
    }
 
}
 
$wsdl = 'http://www.etrzby.cz/assets/cs/prilohy/EETServiceSOAP.wsdl';
 
try {
    $sClient = new MySoap($wsdl, array('trace' => 1));
    /* Force location path - MUST INCLUDE trailing slash
      BUG in ext/soap that does not automatically add / if URL does not contain path cause POST header to be invalid */
 
    $pkp = base64_decode("W7UlA4hXNsDLvCj/eeRAYeOAsNsgMSdltcJNIW98KQRsfspTMW0Lr/OGQgRHZfO5KjolZgzN3k9mgzrVoX2+N90fCNEnOri2kjrW5vzTgMK6OZ9IryAEg0xFZjjjCQ0qKsQsVi8OLQOn3ZnN/BUGG2SIduER+iIOrhfOmes7OXaa5/2jQSfPTHZHZ/Bxhqld3gL4PHvd7sevZYUupHpE1fM7Uw1+lu8i1YOdghZoMyOfKw7FcqvRJpHrW/JZL5Dr5iCgu5ClmhZrb3hZavsxlDG7P2cUhSQgmEVTxJ2n38q/Cf91KE8e52SODN4Q8BfncXpmtkQ7Go3KsRsY3xN7xg==");
 
    $test = $sClient->OdeslaniTrzby([
    "Hlavicka" => [
        "dat_odesl" => "2016-09-19T19:06:37+01:00",
        "prvni_zaslani" => "false",
        "uuid_zpravy" => "9edeb22b-4234-4047-869c-3a76f86c20d3"],
    "Data" => [
        "celk_trzba" => "34113.00",
        "cerp_zuct" => "679.00",
        "cest_sluz" => "5460.00",
        "dan1" => "-172.39",
        "dan2" => "-530.73",
        "dan3" => "975.65",
        "dat_trzby" => "2016-01-05T00:30:12+01:00",
        "dic_popl" => "CZ00000019",
        "id_pokl" => "/5546/RO24",
        "id_provoz" => "273",
        "porad_cis" => "0/6460/ZQ42",
        "pouzit_zboz1" => "784.00",
        "pouzit_zboz2" => "967.00",
        "pouzit_zboz3" => "189.00",
        "rezim" => "0",
        "urceno_cerp_zuct" => "324.00",
        "zakl_dan1" => "-820.92",
        "zakl_dan2" => "-3538.20",
        "zakl_dan3" => "9756.46",
        "zakl_nepodl_dph" => "3036.00"
    ],
    "KontrolniKody" => [
        "pkp" => ["cipher" => "RSA2048", "digest" => "SHA256", "encoding" => "base64", "_" => $pkp],
        "bkp" => ["digest" => "SHA1", "encoding" => "base64", "_" => "1F1A2D90-4EAD34A8-411CFB0B-EB17616E-B2CE8114"]
    ]
        ]);
    
    $request = $sClient->__getLastRequest();  
                 
header("Content-type: text/xml");
 
echo $request;

 
   
    var_dump($test);
} catch (SoapFault $e) {
    var_dump($e);
}

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: