1
我嘗試在SOAP網絡服務來創建CreateOrder方法順序:解決SoapClient錯誤:「對象引用未設置爲對象的實例。」
http://80.72.84.109/MW/services/bilkiservice.asmx?wsdl
這個簡單的代碼:
$soap = new SoapClient(MW_SOAP_URL, array(
"trace" => 1,
"exceptions" => 1
));
//set headers
$headerbody = array(
'Database' => MW_DATABASE,
'Username' => MW_USERNAME,
'Password' => MW_PASSWORD
);
$ns = 'http://tempuri.org/';
$header = new SoapHeader($ns, 'AuthenticationHeader', $headerbody);
$this->soap->__setSoapHeaders($header);
$orderInfo = array(
'OrderNumber' => 23344,
'Email' => '[email protected]',
'Delivery' => array(
'Name' => 'Peter',
'City' => 'LA',
'Post' => 1000,
'Address' => 'Test Street 1',
'Email' => '[email protected]',
'Phone' => '12345'
),
'PaymentType' => 2,
'Items' => array(
'OrderItem' => array(
'Code' => 3479,
'Quantity' => 1,
'TotalPrice' => 2.73
)
)
);
$soap->CreateOrder($orderInfo);
但我總是得到這個錯誤:
object(stdClass)#5 (1) { ["CreateOrderResult"]=> object(stdClass)#6 (4) { ["ErrorMessage"]=> string(53) "Object reference not set to an instance of an object." ["ErrorCode"]=> int(-1) ["Errs"]=> object(stdClass)#7 (0) { } ["OrderID"]=> int(0) } }
我用另一種方法CreateContragent
成功創建了新的反應,但是CreateOrder
沒有工作。
可能是數組數據有誤?但我嘗試了很多配置,沒有任何工作。