Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

SOAP::Lite XML variable with different namespace

by hanspr (Sexton)
on May 09, 2017 at 05:54 UTC ( [id://1189855]=perlquestion: print w/replies, xml ) Need Help??

hanspr has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks I have this signed xml file
<?xml version="1.0" encoding="utf-8"?> <Cancelacion xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="h +ttp://www.w3.org/2001/XMLSchema-instance" Fecha="2017-03-13T15:56:58" + RfcEmisor="AAA010101AAA"> <Folios xmlns="http://cancelacfd.sat.gob.mx"> <UUID>8fb248fb-a7c0-4eb6-bbf4-c11b908b5f8b</UUID> </Folios> <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <SignedInfo> <CanonicalizationMethod Algorithm="http://www.w3.org/TR/20 +01/REC-xml-c14n-20010315" /> <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmld +sig#rsa-sha1" /> <Reference URI=""> <Transforms> <Transform Algorithm="http://www.w3.org/2000/09/xm +ldsig#enveloped-signature" /> </Transforms> <DigestMethod Algorithm="http://www.w3.org/2000/09/xml +dsig#sha1" /> <DigestValue>lNRHb5bj3ovAFJmHzOO/QCjHbl0=</DigestValue +> </Reference> </SignedInfo> <SignatureValue>LImSd9TKyacrFMAK+7TmleQB5p6wEbxCxz61tk0YYusJK6 +tE9DTHgP9aZz4BuHhqYt8Ugf8onHE18ICgRVVhpjN0FYqkNLhhxed62itlsSDCenOyvWt +F2rHnxYHPZWltAQMlUyJijhGgLFWLIg2BEK/rPJCfBsUvgrQ0yulc1eY=</SignatureV +alue> <KeyInfo> <X509Data> <X509IssuerSerial> <X509IssuerName>OID.1.2.840.113549.1.9.2=Responsab +le: Araceli Gandara Bautista, L=Coyoacán, S=Distrito Federal, C=MX, P +ostalCode=06300, STREET="Av. Hidalgo 77, Col. Guerrero", E=asisnet@pr +uebas.sat.gob.mx, OU=Administración de Seguridad de la Información, O +=Servicio de Administración Tributaria, CN=A.C. 2 de pruebas</X509Iss +uerName> <X509SerialNumber>32303030313030303030303230303030 +31343238</X509SerialNumber> </X509IssuerSerial> <X509Certificate>MIIEYTCCA0mg........</X509Certificate> </X509Data> </KeyInfo> </Signature> </Cancelacion>
And I need to send a SOAP Transaction that looks like this (using the previous XML file as input)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xm +lns:suf="http://sufacturacion.com/" xmlns:can="http://cancelacfd.sat. +gob.mx" xmlns:xd="http://www.w3.org/2000/09/xmldsig#"> <soap:Header/> <soap:Body> <suf:Cancelar> <can:cancelacion Fecha="2017-03-13T15:56:58" RfcEmisor="AA +A010101AAA"> <can:Folios> <can:UUID>8fb248fb-a7c0-4eb6-bbf4-c11b908b5f8b</ca +n:UUID> </can:Folios> <xd:Signature> <xd:SignedInfo> <xd:CanonicalizationMethod Algorithm="http://w +ww.w3.org/TR/2001/REC-xml-c14n-20010315" /> <xd:SignatureMethod Algorithm="http://www.w3.o +rg/2000/09/xmldsig#rsa-sha1" /> <xd:Reference URI=""> <xd:Transforms> <xd:Transform Algorithm="http://www.w3 +.org/2000/09/xmldsig#enveloped-signature" /> </xd:Transforms> <xd:DigestMethod Algorithm="http://www.w3. +org/2000/09/xmldsig#sha1" /> <xd:DigestValue>lNRHb5bj3ovAFJmHzOO/QCjHbl +0=</xd:DigestValue> </xd:Reference> </xd:SignedInfo> <xd:SignatureValue>LImSd9TKyacrFMAK+7TmleQB5p6wEbx +Cxz61tk0YYusJK6tE9DTHgP9aZz4BuHhqYt8Ugf8onHE18ICgRVVhpjN0FYqkNLhhxed6 +2itlsSDCenOyvWtF2rHnxYHPZWltAQMlUyJijhGgLFWLIg2BEK/rPJCfBsUvgrQ0yulc1 +eY=</xd:SignatureValue> <xd:KeyInfo> <xd:X509Data> <xd:X509IssuerSerial> <xd:X509IssuerName>OID.1.2.840.113549. +1.9.2=Responsable: Araceli Gandara Bautista, L=Coyoacán, S=Distrito F +ederal, C=MX, PostalCode=06300, STREET="Av. Hidalgo 77, Col. Guerrero +", E=asisnet@pruebas.sat.gob.mx, OU=Administración de Seguridad de la + Información, O=Servicio de Administración Tributaria, CN=A.C. 2 de p +ruebas</xd:X509IssuerName> <xd:X509SerialNumber>32303030313030303 +03030323030303031343238</xd:X509SerialNumber> </xd:X509IssuerSerial> <xd:X509Certificate>MIIEYTCCA0.........</x +d:X509Certificate> </xd:X509Data> </xd:KeyInfo> </xd:Signature> </can:cancelacion> <suf:tokenAutenticacion>T2lYQ0t4L0RHV..........</suf:token +Autenticacion> </suf:Cancelar> </soap:Body> </soap:Envelope>
I've been using SOAP::Data to create the variables but they do not produce the expected output. I have tried replacing parts of the original file to make it look similar to the xml sent in the soap transaction but it is turned into a string and placed inside a variable. I've played in different ways but I really have no clue of how is ti done
my $signed = SOAP::Data->type(string => $XML_CANCELA)->name('cancelaci +on'); or my $signed = SOAP::Data->type(string => $XML_CANCELA)->name('cancelaci +on')->attr({xmlns => 'http://cancelacfd.sat.gob.mx'}); $soap = SOAP::Lite->proxy("${TSERVER}Cancelacion/wsCancelacion.asmx",t +imeout => 30); $soap->default_ns($NameSpace); $soap->on_action(sub {qq¡"${NameSpace}Cancelar"¡}); my $response = $soap->Cancelar(($signed,$tkn));
I have solved using a handler and basically creating the soap envelope by hand, but I wonder if there is a clean solution to it
$soap->transport->add_handler("request_send",\&pp_fixrequest);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1189855]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found