如何摆脱nusoap响应中的额外<return>元素

时间:2017-03-02 11:05:41

标签: php xml soap nusoap

我已成功在nusoap中返回了回复。我的要求是

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:B2BStandardApi">
<x:Header/>
<x:Body>
    <urn:getAccountValidationInput>
        <urn:operationParameters>
            <urn:TransactionReferenceCode>?</urn:TransactionReferenceCode>
            <urn:TransactionDate>2017-03-02T00:00:00</urn:TransactionDate>
        </urn:operationParameters>
        <urn:accountInfo>
            <urn:AccountNumber>00019</urn:AccountNumber>
        </urn:accountInfo>
        <urn:institution>
            <urn:InstitutionCode>?</urn:InstitutionCode>
            <urn:InstitutionName>?</urn:InstitutionName>
        </urn:institution>
    </urn:getAccountValidationInput>
</x:Body>

,响应如下所示,

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 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>headerstring</SOAP-ENV:Header>
<SOAP-ENV:Body>
    <ns1:getAccountValidationOutput xmlns:ns1="urn:B2BStandardApi">
        <return>
            <operationParameters>
                <TransactionReferenceCode xsi:type="xsd:string">CICAM-000080</TransactionReferenceCode>
                <TransactionDate xsi:type="xsd:string">2017-03-02 13:43:59+03:00</TransactionDate>
                <TotalAmount xsi:type="xsd:float">0</TotalAmount>
                <Currency xsi:type="xsd:string"></Currency>
                <AdditionalInfo xsi:type="xsd:string"></AdditionalInfo>
            </operationParameters>
            <accountInfo xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="unnamed_struct_use_soapval[3]">
                <item>
                    <AccountNumber xsi:type="xsd:string">00017-002-00019-003</AccountNumber>
                    <AccountType xsi:type="xsd:string">Equity Fund</AccountType>
                </item>
                <item>
                    <AccountNumber xsi:type="xsd:string">00017-002-00019-004</AccountNumber>
                    <AccountType xsi:type="xsd:string">Fixed Income</AccountType>
                </item>
                <item>
                    <AccountNumber xsi:type="xsd:string">00017-004-00019-002</AccountNumber>
                    <AccountType xsi:type="xsd:string">Money Market</AccountType>
                </item>
            </accountInfo>
            <institution>
                <InstitutionCode xsi:type="xsd:string">CICAM</InstitutionCode>
                <InstitutionName xsi:type="xsd:string">CIC ASSET MANAGEMENT</InstitutionName>
            </institution>
        </return>
    </ns1:getAccountValidationOutput>
</SOAP-ENV:Body>

我想从响应中删除多余的元素,被驱逐的响应应该没有返回标记,

该服务在NuSoapPHP7上运行。

如何删除额外元素

1 个答案:

答案 0 :(得分:1)

经过一番挖掘,我意识到返回标签来自返回参数,所需要的就是使用输入参数作为返回。 初始注册为show

AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
    @Override
    public Void doWork() throws Exception
    {
       ....
       ...
        return null;
    }
});

);

从上面开始,我返回一个数组,它将作为xml元素包含在返回键中,

必填项为

$server->register(
"getAccountValidationInput",
array("operationParameters" => "tns:operationParameters", "accountInfo" => "tns:accountInfo", "institution" => "tns:institution"),
array("return" => "xsd:Array"),
"urn:B2BStandardApi",
"urn:B2BStandardApi#AccountValidation",
"rpc", "literal", "Get member details by member number"

);

返回值为

$server->register(
"getAccountValidationInput",
array("operationParameters" => "tns:operationParameters", "accountInfo" => "tns:accountInfo", "institution" => "tns:institution"),
array("operationParameters" => "tns:Parameters", "accountInfo"=>"tns:accounts", "institution"=>"institution"),
"urn:B2BStandardApi",
"urn:B2BStandardApi#AccountValidation",
"rpc", "literal", "Get member details by member number"