2017-07-14 3 views
1

Comment modifier les attributs xmlns de la balise <SOAP-ENV:Envelope />? J'ai une situation où xmlns:xsi et xmlns:xsd manquent. J'aimerais savoir comment les rajouter?Ajouter les attributs xmlns manquants à SOAP-ENV: Balise Envelope à l'aide de SoapClient dans PHP

Exemple:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns1="http://fedex.com/ws/track/v12"> 
    <SOAP-ENV:Body> 
     <ns1:TrackRequest> 
      ... 

Mais je besoin être ceci:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ns1="http://fedex.com/ws/track/v12" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <SOAP-ENV:Body> 
     <ns1:TrackRequest> 
      ... 

Répondre

0

Je sais que c'est un peu vieux, mais au cas où quelqu'un trébuche sur elle ...

Après tripoter autour avec SoapVar, voici comment cela a fonctionné pour moi:

$params[] = new SoapVar('',XSD_ANYXML, '', null, 'Envelope', 'http://www.w3.org/2001/XMLSchema'); 
$params[] = new SoapVar('',XSD_ANYXML, '', null, 'Envelope', 'http://www.w3.org/2001/XMLSchema-instance'); 
//you can add more vars here. 
//E.g. in my case I also needed $params[] = new SoapVar('<notifications xmlns="http://soap.sforce.com/2005/09/outbound"><Ack>true</Ack></notifications>',XSD_ANYXML); as I was working with salesforces soap. 
return new SoapVar($params, XSD_ANYXML);