doushui3061 2014-02-25 10:10
浏览 157

在PHP中将多个对象放入数组中

I made a web service with ASP.NET WorkFlow Foundation and I want to consume it with PHP. I used EasyWSDL2PHP to generated the php reference file for calling the web service. Here is a sample of an UpdateObject method:

function UpdateObject($UpdateObject)
{
$int = $this->soapClient->UpdateObject($UpdateObject);
return $int;
}

So I can call this method with an $UpdateObject object which is defined in another place of the ref. file:

class UpdateObject{
var $objList;//ArrayOfObjectStore
var $by;//string
var $dt;//string
}

The $objList is a List of ObjectStore which I have defined in .NET. The ref class file has also describe it like this:

class ArrayOfObjectStore{
var $ObjectStore;//ObjectStore
}

And of course the ObjectStore is an object with some properties like this:

class ObjectStore{
var $category;//string
var $code;//string
var $create_by;//string
var $create_datetime;//dateTime
var $description;//string
var $modify_by;//string
var $modify_datetime;//dateTime
var $name;//string
}

For you reference, the signature of this method in .NET is :

Public Function UpdateObject(objList As List(Of ObjectStore),
         by As String, dt As String) As Integer

OK. I tried to call the web service by having one ObjectStore object in the list and it works good. However I don't know how to put more than one object into the list.

For your reference, here is how I make the call successfully with 1 object in the list:

 $test = new MyClass();

 $obj = new ObjectStore();
 $obj->category = 'test';
 $obj->code = 'test';
 $obj->description='test';
 $obj->modify_by='test';
 $obj->name='test';
 $obj->sys_abbr='test';
 $obj->sys_code='test';

 $objList = new ArrayOfObjectStore();
 $objList->ObjectStore = $obj;

 $updateObj = new UpdateObject();
 $updateObj->objList = $array;
 $updateObj->by = 'test';
 $updateObj->dt = '2014-2-22 22:22:22';

 $result = $test->UpdateObject($updateObj);

 echo $result;

How do I make multiple objects into the list? I have tried array_push() and $updateObj->objList->append() but they both not working. Please give me some suggestion. Thank you for your help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。