PHPSOAP:如何在xml头和体标记中获取参数

PHPSOAP:如何在xml头和体标记中获取参数,php,xml,soap,nameservers,soapheader,Php,Xml,Soap,Nameservers,Soapheader,在PHP中,我需要创建一个soap xml请求,如 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.or

在PHP中,我需要创建一个soap xml请求,如

   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">

    <SOAP-ENV:Header xmlns:NS1="urn:UCoSoapDispatcherBase" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <NS1:TAuthenticationHeader xsi:type="NS1:TAuthenticationHeader">
    <UserName xsi:type="xsd:string">user</UserName>
    <Password xsi:type="xsd:string">pass</Password>
    </NS1:TAuthenticationHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <NS2:ExecuteRequest xmlns:NS2="urn:UCoSoapDispatcherCustomLink-ICustomLinkSoap">
    <ARequest xsi:type="xsd:string">
    <?xml version="1.0" encoding="windows-1252"?> <EoCustomLinkRequestDateTime Type="TEoCustomLinkRequestDateTime"></EoCustomLinkRequestDateTime>
    </ARequest>
    </NS2:ExecuteRequest>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

用户
通过
但问题是在头(比如xmlns:NS1…)和主体(比如xmlns:NS2…)标记中获取param 在我的脚本中,NS1和NS2在头和体之后的第一个标记中交换。结果是
。。。。和<代码>

我的php脚本:

<?php

$wsdl_url = 'http://xxx.xxx.xxx.xxx:yyyy/wsdl/ICustomLinkSoap';
$location = 'http://xxx.xxx.xxx.xxx:yyyy/soap/ICustomLinkSoap';
$action = 'ExecuteRequest';
$version = SOAP_1_1;
$one_way = 0;


$soapClient = new SoapClient($wsdl_url, array(
    'cache_wsdl'    => WSDL_CACHE_NONE,
    'trace'         => true,
    'encoding'  => 'ISO-8859-1',
    'exceptions'    => true,

));

$auth = (object)array(
        'UserName'=>'xxxx',
        'Password'=>'yyyy'
        );
$header = new SoapHeader($wsdl_url,'TAuthenticationHeader',$auth,false);
$soapClient->__setSoapHeaders($header);

$request1  = '
<ARequest>
&lt;?xml version="1.0" encoding="windows-1252"?&gt;

        &lt;EoCustomLinkRequestDateTime Type="TEoCustomLinkRequestDateTime" xsi:noNamespaceSchemaLocation="GdxEoStructures.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;

        &lt;/EoCustomLinkRequestDateTime&gt;</ARequest>
';

$xmlVar = new SoapVar($request1, XSD_ANYXML);

$result = $soapClient->__SoapCall(
    'ExecuteRequest',
    array($xmlVar)
);

// show result in xml-file
$f = fopen("./soap-request2.xml", "w");
xx = serialize($soapClient->__getLastRequest());
fwrite($f, $xx);

?>
\u SoapCall(
“ExecuteRequest”,
数组($xmlVar)
);
//在xml文件中显示结果
$f=fopen(“./soap-request2.xml”,“w”);
xx=序列化($soapClient->uu getLastRequest());
fwrite($f,$xx);
?>
结果:

    <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:ns1="urn:UCoSoapDispatcherCustomLink-ICustomLinkSoap" 
    xmlns:ns2="http://xxx.xxx.xxx.xxx:yyy/wsdl/ICustomLinkSoap" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
    SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

    <SOAP-ENV:Header>
        <ns2:TAuthenticationHeader>
            <UserName>xxxx</UserName>
            <Password>yyyy</Password>
        </ns2:TAuthenticationHeader>
    </SOAP-ENV:Header>

    <SOAP-ENV:Body>
        <ns1:ExecuteRequest>
            <ARequest>
            &lt;?xml version="1.0" encoding="windows-1252"?&gt;
        &lt;EoCustomLinkRequestDateTime Type="TEoCustomLinkRequestDateTime" xsi:noNamespaceSchemaLocation="GdxEoStructures.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
        &lt;/EoCustomLinkRequestDateTime&gt;
        </ARequest>
        </ns1:ExecuteRequest>
    </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

xxxx
年份
?xml version=“1.0”encoding=“windows-1252”?
EoCustomLinkRequestDateTime Type=“TEoCustomLinkRequestDateTime”xsi:noNamespaceSchemaLocation=“GdxEoStructures.xsd”xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance"
/EoCustomLinkRequestDateTime
请帮忙怎么做

埃里克

但问题是在头中获取param(比如xmlns:NS1…)和 主体(如xmlns:NS2…)标记与脚本一起交换NS1和NS2 在标题和正文之后的第一个标记中。导致 .... 和

这不是问题,因为不仅交换了元素的名称空间,还交换了SOAP-ENV:Envelope头部的定义

您的第一个xml

xmlns:NS1="urn:UCoSoapDispatcherBase"
xmlns:NS2="urn:UCoSoapDispatcherCustomLink-ICustomLinkSoap"
与php生成的

xmlns:ns1="urn:UCoSoapDispatcherCustomLink-ICustomLinkSoap" 
xmlns:ns2="http://xxx.xxx.xxx.xxx:yyy/wsdl/ICustomLinkSoap"