简体   繁体   中英

Error when calling WCF function with two arguments

My WCF service have method that accepts two parameters. In object browers this method looks like

public wcfelmaservice.racun SendOrder(wcfelmaservice.order Order_Header, System.Collections.Generic.List<order_items> Order_Items)

Order_Header have two members:

public string Number { set; get; }
public string Name { set; get; }

Order_Items have these members:

public decimal Price { set; get; }
public decimal Qty { set; get; }
public string ItemName { set; get; }

Now I have to pass values from PHP to WCF service. I'm doing it on this way:

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

?>

When I run this script i get error:

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.

I have no idea what I'm doing wrong?

PHP is not my forte, but a quick search on SO and I found this: How to serialize an "Object" type in PHP to be sent to a WCF Service? . Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM