Home » Php » nusoap: how to select which Nested ComplexType to use?

nusoap: how to select which Nested ComplexType to use?

Posted by: admin August 13, 2018 Leave a comment

Questions:

I have an issue with a nuSoap client (using a WSDL) where one of the params is being sent as empty, which i think is because I don’t know how to define which complexType to send the params as.

So for example:

$TelephoneNumberAvailabilityRequest = [
        'MACCode'           => new soapval("MACCode", "xsd:nil", null),
        'PerformMPFACCheck' => 'No',
        'Postcode'          => 'NW1 4DJ',
        'ProxyCLI'          => false,
        'TelephoneNumber'   => '0123456789',
    ];

$payload = [
        'request' => [
            'AccessCircuit' => ['string' => ['All', 'FTTP']],
            'RequestDetails' => [
//                    'AvailabilityRequest' => [
                    'TelephoneNumberAvailabilityRequest' => 
$TelephoneNumberAvailabilityRequest,
//                    ],
            ],
        ],
    ];

$result = $client->call($method,[$payload]);

this gets sent to the server as:

<?xml version="1.0" encoding="UTF-8"?>
<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/" xmlns:ns7756="http://tempuri.org">
 <SOAP-ENV:Body>
  <GetAvailability xmlns="http://xxxxxxxxxxx">
   <request>
    <AccessCircuit>
     <string>All</string>
     <string>FTTP</string>
    </AccessCircuit>
    <RequestDetails>   <!--    WHY IS THIS EMPTY :-(     -->
    </RequestDetails>
   </request>
  </GetAvailability>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The RequestDetails param has 3 or 4 different possible complexTypes that could be used, but i specifically want to use the one named TelephoneNumberAvailabilityRequest

I’ve tried lots of combinations of defining the payload, such as

'RequestDetails' => [
        'MACCode'           => new soapval("MACCode", "xsd:nil", null),
        'PerformMPFACCheck' => 'No',
        'Postcode'          => 'NW1 4DJ',
        'ProxyCLI'          => false,
        'TelephoneNumber'   => '0123456789',
    ],

What I am trying to acheive is to send:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:net="http://xxxxxxxx/NetworkProductAvailabilityCheckerService" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <soapenv:Header/>
    <soapenv:Body>
        <net:GetAvailability>
            <net:request>
                <net:AccessCircuit>
                    <arr:string>All</arr:string>
                </net:AccessCircuit>
                <net:NominatedCLIRequestDetails>
                    <net:CLI>0123456789</net:CLI>
                    <net:NumberRetentionCode>0</net:NumberRetentionCode>
                    <net:Retain>Yes</net:Retain>
                </net:NominatedCLIRequestDetails>
                <net:RequestDetails xsi:type="net:TelephoneNumberAvailabilityRequest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                    <net:MACCode xsi:nil="true" />
                    <net:PerformMPFACCheck>No</net:PerformMPFACCheck>
                    <net:Postcode>NW1 4DJ</net:Postcode>
                    <net:ProxyCLI>false</net:ProxyCLI>
                    <net:TelephoneNumber>0123456789</net:TelephoneNumber>
                </net:RequestDetails>
                <net:UserConsent>Yes</net:UserConsent>
            </net:request>
        </net:GetAvailability>
    </soapenv:Body>
</soapenv:Envelope>

but just does not want to work???

Answers: