Promit
Promit

Reputation: 140

3PL Central PHP SOAP Request Error Sequence contains no elements

I'm Trying to integrate Create Order in 3PL Central, using there SOAP API.

Here is my code::

//Request Array
$req_arr = [
    'extLoginData' => [
        'ThreePLKey' => 'key',
        'Login' => 'user',
        'Password' => 'pass',
        'FacilityID' => 123,
        'CustomerID' => 100
    ],
    'orders' => [
        'Order' => [
            'TransInfo' => [
                'ExpectedDate' => '2017-02-11T00:00:00',
                'ReferenceNum' => 'TESTN%$',
            ],
            'ShipTo' => [
                'Name' => 'Test Test', //[OPTIONAL]
                'CompanyName' => 'Test Address',
                'Address' => [
                    'Address1' => '1212 Main Street',
                    'City' => 'Los Angeles',
                    'State' => 'CA',
                    'Zip' => '90010',
                    'Country' => 'US'
                ],
                'PhoneNumber1' => '34343434324', //[OPTIONAL]
                'Fax' => '9856326352', //[OPTIONAL]
                'EmailAddress1' => '[email protected]', //[OPTIONAL]
                'CustomerName' => 'test', //[OPTIONAL]
                'Vendor' => 'Any', //[OPTIONAL]
                'Dept' => 'Any', //[OPTIONAL]
                'RetailerID' => 343 //[OPTIONAL – do not send if not matching with value in the 3PL Central]
            ],
            'Notes' => 'Test',
            'PalletCount' => 10, //[OPTIONAL – do not send if not matching with value in the 3PL Central]
        ]
    ],
    'warnings' => 'test'
];

//SOAP options
$options = [
    'uri' => 'http://schemas.xmlsoap.org/soap/envelope/',
    'style' => SOAP_RPC,
    'use' => SOAP_ENCODED,
    'soap_version' => SOAP_1_2,
    'trace' => true,
    'cache' => WSDL_CACHE_NONE,
    'exceptions' => true,
    "features" => SOAP_SINGLE_ELEMENT_ARRAYS,
    'encoding' => 'UTF-8',
    'connection_timeout' => 15,
    'Content-Type' => 'application/soap+xml; charset=utf-8',
    'Content-Length' => strlen(json_encode($req_arr)),
    'SOAPAction' => 'http://www.JOI.com/schemas/ViaSub.WMS/CreateOrders'
];

$client = new \SoapClient('https://secure-wms.com/webserviceexternal/contracts.asmx?wsdl', $options);
$result = $client->__soapCall('CreateOrders', $req_arr);

I'm getting an error

Server was unable to process request. ---> Sequence contains no elements

I google allot for this and in concluded that issue is with the XML which is generated by the array but using some PHP script (array to XML converter) I successful converted the array to XML so there might not be any error in XML.
Is the issue is with the SOAP option that I have set?

Thanks.

This the API Doc Link.

Upvotes: 1

Views: 463

Answers (1)

ryo7689
ryo7689

Reputation: 136

The request array is missing parameters (there are more parameters under an order), according to the documentation. Although some of them are optional, but I am not too sure why the parameters are still required when I was implementing the function using PHP.

Upvotes: 1

Related Questions