【发布时间】:2010-10-04 01:29:03
【问题描述】:
我有一个包含三种方法的 WCF 服务。其中两个方法返回自定义类型(这些按预期工作),第三个方法将自定义类型作为参数并返回一个布尔值。当通过 PHP soap 客户端调用第三个方法时,它返回一个“对象引用未设置为对象的实例”异常。
示例自定义类型:
_ 公开课 MyClass
Private _propertyA As Double
<DataMember()> _
Public Property PropertyA() As Double
Get
Return _propertyA
End Get
Set(ByVal value As Double)
_propertyA = value
End Set
End Property
Private _propertyB As Double
<DataMember()> _
Public Property PropertyB() As Double
Get
Return _propertyB
End Get
Set(ByVal value As Double)
_propertyB = value
End Set
End Property
Private _propertyC As Date
<DataMember()> _
Public Property PropertyC() As Date
Get
Return _propertyC
End Get
Set(ByVal value As Date)
_propertyC = value
End Set
End Property
结束类
方法:
公共函数 Add(ByVal param As MyClass) As Boolean 实现 IService1.Add ' ... 结束函数
PHP 客户端调用:
$client->Add(array('param'=>array( '属性A' => 1, '属性B' => 2, 'PropertyC' => "2009-01-01" )));
WCF 服务在 .Net 客户端上运行良好,但我是 PHP 新手,无法使其正常工作。
是否可以在 PHP 中创建“MyClass”的实例。
任何帮助将不胜感激。
注意:我使用的是 PHP 5(XAMPP 1.7.0 for Windows)。
谢谢
马特
【问题讨论】:
-
你试过 $myClassInstance = new $Client->MyClass();
-
Matt -- 你有没有找到解决这个问题的方法?我遇到了类似的问题,PHP 无法将类实例传递给 Web 服务。
-
@Steve:请看下面我的回答。
-
我们最终解决了我们的问题。它是 PHP 中 array() 的嵌套。我们需要另一个 array() 嵌套来使其工作。 .NET 似乎在 SOAP 中添加了另一个抽象层,仅查看 .NET 中的服务定义并不清楚。