我的WCF服務具有接受兩個參數的方法。在對象的browers這種方法看起來像使用兩個參數調用WCF函數時出錯
public wcfelmaservice.racun SendOrder(wcfelmaservice.order Order_Header, System.Collections.Generic.List<order_items> Order_Items)
Order_Header有兩個成員:
public string Number { set; get; }
public string Name { set; get; }
ORDER_ITEMS有這些成員:
public decimal Price { set; get; }
public decimal Qty { set; get; }
public string ItemName { set; get; }
現在我已經從PHP值傳遞給WCF服務。我做它是這樣的:
<?php
$wcfClient = new SoapClient('http://localhost:28309/Service1.svc?wsdl');
ini_set("soap.wsdl_cache_enabled", "0");
//var_dump($wcfClient->__getFunctions());
$header = new StdClass;
$header->Number="1";
$header->Name="Test d.o.o";
$item = new StdClass;
$item->Price = "10.00";
$item->Qty="5";
$item->ItemName="SomeItemName";
$paramHeader = array ('Order_Header' => $header);
$paramItems = array ('Order_Items' => $item);
$response = $wcfClient->SendOrder($paramHeader, $paramsItems);
?>
當我運行此腳本,我得到錯誤:
Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SendOrder'. End element 'Body' from namespace ' http://schemas.xmlsoap.org/soap/envelope/ ' expected.
我不知道我做錯了嗎?
我不知道PHP,但是你的WCF方法的簽名有一個'Order_Header'實例和一個'Order_Item'集合,並且在你的腳本中傳遞了一個'Order_Header'數組。嘗試僅傳入'Order_Header'的單個實例並查看是否可行。 '$ response = $ wcfClient-> SendOrder($ header,$ paramsItems);' – Tim
同樣的錯誤 – Josef