2017-07-14 34 views
1

如何编辑<SOAP-ENV:Envelope />标记的xmlns属性?将缺少的xmlns属性添加到SOAP-ENV中:使用PHP中的SoapClient添加信封标记

我有一个情况,其中xmlns:xsixmlns:xsd丢失。我想知道如何将它们添加回来?

例子:

<?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> 
      ... 

但我需要它是这样的:

<?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> 
      ... 

回答

0

我知道这是有点老了,但万一有人绊倒在它...

摆弄后与SoapVar,这是它是如何工作对我来说:

$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); 
相关问题