Ally
Ally

Reputation: 21

How do i get rid of the extra <return> element in nusoap response

I have successfully returned a response in nusoap. The request i have is

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

and the response is as shown below,

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

I would like to remove the extra element from the reponse, the expetected reponse should not have a return tag,

The service runs on NuSoapPHP7.

How can I remove the extra element

Upvotes: 0

Views: 594

Answers (1)

Ally
Ally

Reputation: 21

After some digging, I realized found out that the return tag was from the return parameters, All that was required was to use the input parameters as the return. Initial register was as show

$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"

);

From the above, i was returning an array which would be wrapped inside the return key as an xml element,

The required is as

$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"

);

The return values would be as

<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>headerstring</SOAP-ENV:Header>
<SOAP-ENV:Body>
    <ns1:getAccountValidationOutput xmlns:ns1="urn:B2BStandardApi">
        <operationParameters>
            <TransactionReferenceCode>CICAM-000114</TransactionReferenceCode>
            <TransactionDate>2017-03-03 11:02:53+03:00</TransactionDate>
            <TotalAmount>0</TotalAmount>
            <Currency></Currency>
            <AdditionalInfo/>
        </operationParameters>
        <accountInfo>
            <item>
                <AccountNumber>0001700200019004</AccountNumber>
                <AccountName>Fixed Income</AccountName>
            </item>
        </accountInfo>
        <institution>
            <InstitutionCode>CICAM</InstitutionCode>
            <InstitutionName>ASSET MANAGEMENT</InstitutionName>
        </institution>
    </ns1:getAccountValidationOutput>
</SOAP-ENV:Body>

Upvotes: 1

Related Questions