3PL Central PHP SOAP请求错误序列不包含任何元素

时间:2017-04-18 12:53:43

标签: php xml soap soap-client

我正在尝试使用SOAP API在3PL Central中集成Create Order。

这是我的代码::

//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' => 'test@example.com', //[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);

我收到错误

  

服务器无法处理请求。 --->序列包含否   元素

我谷歌分配这个,并得出结论,问题是由数组生成但使用一些PHP脚本(数组到XML转换器)的XML我成功将数组转换为XML,因此XML中可能没有任何错误。
问题出在我设置的SOAP选项上吗?

感谢。

这是API Doc Link

1 个答案:

答案 0 :(得分:1)

根据文档,请求数组缺少参数(订单下有更多参数)。虽然其中一些是可选的,但我不太清楚为什么在使用PHP实现函数时仍然需要参数。