简体   繁体   English

使用两个参数调用WCF函数时出错

[英]Error when calling WCF function with two arguments

My WCF service have method that accepts two parameters. 我的WCF服务具有接受两个参数的方法。 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: Order_Header具有两个成员:

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

Order_Items have these members: Order_Items具有以下成员:

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. 现在,我必须将值从PHP传递到WCF服务。 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'. 致命错误:未捕获的SoapFault异常:[a:DeserializationFailed]格式化程序在尝试反序列化消息时引发了异常:反序列化操作'SendOrder'的请求消息正文时出错。 End element 'Body' from namespace ' http://schemas.xmlsoap.org/soap/envelope/ ' expected. 预期来自名称空间“ http://schemas.xmlsoap.org/soap/envelope/ ”的元素“ Body”。

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? PHP不是我的强项,而是对SO的快速搜索,我发现了这一点: 如何在PHP中序列化“对象”类型以发送到WCF服务? . Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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