php SoapClient override\uuu dorequest在str\u replace之后不会更改xml
为了向元素添加属性,我重写了php SoapClient类。当我打印更改的代码时,就在发送之前,XML似乎按照预期进行了更改,但当通过u getLastRequest()检查XML时,XML似乎根本没有更改。在代码中,我尝试向元素添加属性。也许有人知道为什么$request\u新XML字符串没有发送到服务器?(OutputXML()只是一些很好的格式设置,可以将其合并为html)php SoapClient override\uuu dorequest在str\u replace之后不会更改xml,php,soap,Php,Soap,为了向元素添加属性,我重写了php SoapClient类。当我打印更改的代码时,就在发送之前,XML似乎按照预期进行了更改,但当通过u getLastRequest()检查XML时,XML似乎根本没有更改。在代码中,我尝试向元素添加属性。也许有人知道为什么$request\u新XML字符串没有发送到服务器?(OutputXML()只是一些很好的格式设置,可以将其合并为html) 类SoapClientDebug扩展了SoapClient { 公共函数\u doRequest($request、
类SoapClientDebug扩展了SoapClient
{
公共函数\u doRequest($request、$location、$action、$version、$one\u way=0){
//更改/添加任何需要的内容
$request\u new=str\u replace(“我明白了为什么,回答我自己的问题可能有点奇怪,但可能对将来的某个人有所帮助;结果是,\uuu getLastRequest()不是本例中实际的最后一个请求。因此,重写\uu doRequest是一个选项,但在这种情况下不要使用\uu getLastRequest
class SoapClientDebug extends SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
// change / add whatever needed
$request_new = str_replace( '<env:Body', '<env:Body ns1:Id="TheBody"', $request );
// debug out
OutputXML($request_new);
// calling parent
return parent::__doRequest($request_new, $location, $action, $version, $one_way);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://logius.nl/digipoort/koppelvlakservices/1.2/" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://schemas.xmlsoap.org/soap/security/2000-12">
<env:Header>
<ns3:Security env:mustUnderstand="true">
<ns2:Signature>
<ns2:SignedInfo>
<ns2:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ns2:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<ns2:Reference>
<ns2:Transforms>
<ns2:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ns2:Transforms>
<ns2:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ns2:DigestValue>$6hpmccmjxQmAI143OhQfIWpkryw=</ns2:DigestValue>
</ns2:Reference>
</ns2:SignedInfo>
<ns2:SignatureValue>sv8n4h0rV4Xmbl+M+w+MLl7lVA8KFsoWRx5DqSKkwSie32jOFoJt0WvH6UWRQI</ns2:SignatureValue>
<ns2:KeyInfo>
<ns2:X509Data>
<ns2:X509IssuerName>CN=TestSignCert</ns2:X509IssuerName>
<ns2:X509SerialNumber>75496503122422458150193540449068096025</ns2:X509SerialNumber>
</ns2:X509Data>
</ns2:KeyInfo>
</ns2:Signature>
</ns3:Security>
</env:Header>
<env:Body ns1:Id="TheBody">
<ns1:aanleverRequest>
<ns1:berichtsoort>Omzetbelasting</ns1:berichtsoort>
<ns1:aanleverkenmerk>Happyflow</ns1:aanleverkenmerk>
<ns1:identiteitBelanghebbende>
<ns1:nummer/>
<ns1:type/>
</ns1:identiteitBelanghebbende>
<ns1:rolBelanghebbende>Intermediair</ns1:rolBelanghebbende>
<ns1:berichtInhoud>
<ns1:mimeType/>
<ns1:bestandsnaam/>
<ns1:inhoud/>
</ns1:berichtInhoud>
<ns1:autorisatieAdres>https://secure.inepd.nl/inloon</ns1:autorisatieAdres>
</ns1:aanleverRequest>
</env:Body>
</env:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://logius.nl/digipoort/koppelvlakservices/1.2/" xmlns:ns2="http://www.w3.org/2000/09/xmldsig#" xmlns:ns3="http://schemas.xmlsoap.org/soap/security/2000-12">
<env:Header>
<ns3:Security env:mustUnderstand="true">
<ns2:Signature>
<ns2:SignedInfo>
<ns2:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ns2:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<ns2:Reference>
<ns2:Transforms>
<ns2:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ns2:Transforms>
<ns2:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ns2:DigestValue>$6hpmccmjxQmAI143OhQfIWpkryw=</ns2:DigestValue>
</ns2:Reference>
</ns2:SignedInfo>
<ns2:SignatureValue>sv8n4h0rV4Xmbl+M+w+MLl7lVA8KFsoWRx5DqSKkwSie32jOFoJt0WvH6UWRQI</ns2:SignatureValue>
<ns2:KeyInfo>
<ns2:X509Data>
<ns2:X509IssuerName>CN=TestSignCert</ns2:X509IssuerName>
<ns2:X509SerialNumber>75496503122422458150193540449068096025</ns2:X509SerialNumber>
</ns2:X509Data>
</ns2:KeyInfo>
</ns2:Signature>
</ns3:Security>
</env:Header>
<env:Body>
<ns1:aanleverRequest>
<ns1:berichtsoort>Omzetbelasting</ns1:berichtsoort>
<ns1:aanleverkenmerk>Happyflow</ns1:aanleverkenmerk>
<ns1:identiteitBelanghebbende>
<ns1:nummer/>
<ns1:type/>
</ns1:identiteitBelanghebbende>
<ns1:rolBelanghebbende>Intermediair</ns1:rolBelanghebbende>
<ns1:berichtInhoud>
<ns1:mimeType/>
<ns1:bestandsnaam/>
<ns1:inhoud/>
</ns1:berichtInhoud>
<ns1:autorisatieAdres>https://secure.inepd.nl/inloon</ns1:autorisatieAdres>
</ns1:aanleverRequest>
</env:Body>
</env:Envelope>