duanne9313 2014-01-29 12:20
浏览 71
已采纳

从stdClass对象创建PHP SOAP消息

So I have soap connection to some services. The App I'm creating is fully object oriented. The data for messages I'm sending are therefore in PHP in stdClass objects (it is extended by my Classes - representants of data in future xml document with predeclared public $variables). Everything is fine as long as I have to create documents like:

<Request>
<paramsList>
<someParam></someParam>
<someParam></someParam>
<someParam></someParam>
<someParam></someParam>
</paramsList>
<moreData></moreData>
</Request>

Now the problem is to create structure like:

<Request>
<paramsList>
<someParam id="3"></someParam>
<someParam id="4"></someParam>
<someParam id="18"></someParam>
<someParam id="512"></someParam>
</paramsList>
<moreData isImportant="false"></moreData>
</Request>

Is it possible (and if - how?) to add these things to stdObject so I don't have to change execution of SOAP functions from this simple form:

$client->functionToExecute($stdObjectOrientedData);

Example object and usage:

class Request extends \stdClass
{
    public $paramsList;
    public $moreData;
}

$objectToSend = new \stdObject();
$request = new Request();
$request->paramsList = $someParamsObjectsArray;
$request->moreData = $someData;
$objectToSend->Request = $request;

$client->functionToExecute($objectToSend);
  • 写回答

1条回答 默认 最新

  • dpxf81245 2014-03-14 11:57
    关注

    In case someone visit this question, here is the answer.

    If WSDL file is created properly, PHP will generate response with using normal StdClass objects. just name properties as they are named in request.

    If WSDL has errors, only thing you can do is to make requests manualy from templates.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line