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

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

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)