dongwenhui8900 2017-04-10 16:04 采纳率: 0%
浏览 10
已采纳

一系列肥皂变量[关闭]

I am picking up some code (soap related) and I am not sure if its "best practice" I was wondering if someone could point me in the right direction.

$requests = new stdClass();
$requests->rq = new stdClass();
$requests->rq->SessionId = $session;
$requests->rq->FareSourceCode = $searchs->fare_source_code;
$requests->rq->TravelerInfo = new stdClass();
$requests->rq->TravelerInfo->AirTravelers = new stdClass();
$parametersLike4LikeSector1[] = new SoapVar('M', XSD_STRING, null,null,'ns1:Gender');
$parametersLike4LikeSector1[] = new SoapVar('JOE', XSD_STRING, null, null,'ns1:PassengerFirstName');

$parametersLike4LikeSector1[] = new SoapVar('BLOGGS', XSD_STRING, null, null,'ns1:PassengerLastName');

$objectLike4Like[] = new SoapVar($parametersLike4LikeSector1, SOAP_ENC_OBJECT, null, null,'ns1:AirTraveler');

$requests->rq->TravelerInfo->AirTravelers = new SoapVar($objectLike4Like, SOAP_ENC_OBJECT);
  • 写回答

1条回答 默认 最新

  • dongyejun1983 2017-04-10 16:27
    关注

    "Best Practice" depends on opinion. You will find a lot of code that works, some work better than other, but in the end you just need to find what works for you. We have a lot of developers working with us and they use SOAP parameters the same way you have it there.. you could also do

    $params = array('apiParam1' => $someVariable, 'apiParam2' => $someVariable); 
    

    And then pass that array in the following call to the webservice:

    $client = new SoapClient($wsdlUrl, array('trace' => true, 'exceptions' => true);
    
    $response = $client->__soapCall($apiMethod, array('parameters' => $params));
    

    Some webservices have 'params' instead of 'parameters' in above call.

    Hope this gives clarity

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

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效