nusoap icon indicating copy to clipboard operation
nusoap copied to clipboard

Nested ComplexType

Open shopapps opened this issue 6 years ago • 3 comments

Hi,

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>

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

  • any advise gratefuly received :-)

shopapps avatar May 18 '18 11:05 shopapps

Hi, it's so complicated. I can't help you. Perhaps somebody else?

f3l1x avatar May 20 '18 19:05 f3l1x

As i can see in nusoap code, nusoap is working with wsdl. in wsdl that provides server there is no key "TelephoneNumberAvailabilityRequest" in "RequestDetails". Probably if you will use it without that key, you will have more success.

try to put your nested code 1 level up

something like:

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

evilangelmd avatar Aug 01 '18 14:08 evilangelmd

Thanks for the response... Am not sure if doing it that way will set the "xsi:type" to "TelephoneNumberAvailabilityRequest" but next time I am looking at that particular code I will give it a try.

Regards, Paul.

shopapps avatar Aug 01 '18 14:08 shopapps