2

如何编辑<SOAP-ENV:Envelope />标签的 xmlns 属性?

我有一种情况,xmlns:xsi并且xmlns: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>
          ...
4

1 回答 1

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);
于 2017-11-16T12:48:01.347 回答