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 对于这个问题的代码运行
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败