请问php soap请求是如何使用的啊?

发布于 2022-09-12 23:13:43 字数 4653 浏览 28 评论 0

$wsdl ="https://www.xxx.com/services/test.svc?wsdl";
        libxml_disable_entity_loader(false);
        $opts = array(
            'ssl'   => array(
                'verify_peer'          => false
            ),
            'https' => array(
                'curl_verify_ssl_peer'  => false,
                'curl_verify_ssl_host'  => false
            )
        );
        $streamContext = stream_context_create($opts);
        $client = new \SoapClient($wsdl,
            array(
                'stream_context'    => $streamContext
            ));
        echo '<pre>';print_r($client->__getFunctions());
        echo '<pre>';print_r($client->__getTypes());

得到:

Array
(
    [0] => AddRepairAppointmentResponse AddRepairAppointment(AddRepairAppointment $parameters)
    [1] => AddFaultItemResponse AddFaultItem(AddFaultItem $parameters)
    [2] => AddOrUpdateMemberSatisfactionResponse AddOrUpdateMemberSatisfaction(AddOrUpdateMemberSatisfaction $parameters)
    [3] => AddCarinfoAssemblysResponse AddCarinfoAssemblys(AddCarinfoAssemblys $parameters)
)
Array
(
    [0] => struct AddRepairAppointment {
 ArrayOfRepairAppointment data;
}
    [1] => struct ArrayOfRepairAppointment {
 RepairAppointment RepairAppointment;
}
    [2] => struct RepairAppointment {
 string AppointNo;
 string CellPhoneNumber;
 string CustomerName;
 string DealerCode;
 string Expend1;
 string Expend2;
 string Expend3;
 string Expend4;
 string Expend5;
 string IsWx;
 string LicensePlate;
 int Mileage;
 string MotorSeries;
 string MotorType;
 dateTime PlanArriveDate;
 string PlanArriveTime;
 int RepairType;
 int Status;
 string VinCode;
}
    [3] => struct AddRepairAppointmentResponse {
 OperationResult AddRepairAppointmentResult;
}
    [4] => struct OperationResult {
 int Code;
 string Message;
}
    [5] => struct AddFaultItem {
 ArrayOfFaultItem data;
}
    [6] => struct ArrayOfFaultItem {
 FaultItem FaultItem;
}
    [7] => struct FaultItem {
 string Code;
 int Id;
 int Level;
 string Name;
 int ParentId;
}
    [8] => struct AddFaultItemResponse {
 OperationResult AddFaultItemResult;
}
    [9] => struct AddOrUpdateMemberSatisfaction {
 ArrayOfMemberSatisfaction data;
}
    [10] => struct ArrayOfMemberSatisfaction {
 MemberSatisfaction MemberSatisfaction;
}
    [11] => struct MemberSatisfaction {
 int Attitude;
 int Environment;
 int Fee;
 string Member_name;
 string Message;
 string Phone_no;
 dateTime Review_time;
 int Satisfaction;
 string Settle_no;
 int Skills;
 int Time_liness;
 string Vin_code;
}
    [12] => struct AddOrUpdateMemberSatisfactionResponse {
 OperationResult AddOrUpdateMemberSatisfactionResult;
}
    [13] => struct AddCarinfoAssemblys {
 ArrayOfCarinfoAssembly data;
}
    [14] => struct ArrayOfCarinfoAssembly {
 CarinfoAssembly CarinfoAssembly;
}
    [15] => struct CarinfoAssembly {
 string Batch_Code;
 string Body_Num;
 string Car_Material_Code;
 string Color_Code;
 string Engine_Num;
 string Export_Code;
 string Factory_Code;
 string Gear_Num;
 string Line_Name;
 string Offline_Time;
 string Online_Time;
 string PT_Online_Time;
 string Prd_Num;
 string QC_Num;
 string QC_Time;
 string RS1;
 string RS2;
 string RS3;
 string RS4;
 string RS5;
 string Remark;
 string Sales_Code;
 string To_Warehouse_Time;
 int Trans_Mark;
 string Vin_Batch_Code;
 string Vin_Code;
 string Year_Code;
}
    [16] => struct AddCarinfoAssemblysResponse {
 OperationResult AddCarinfoAssemblysResult;
}
    [17] => int char
    [18] => duration duration
    [19] => string guid
)

然后请求:

$param = [
            'AppointNo'=>'201905170111', //预约单号(车主俱乐部单号)
            'CellPhoneNumber'=>'18888889999', //车主电话
            'CustomerName'=>'李三',
            'DealerCode' => '13885',
            'Expend1' => '开新',
            'Expend2' => '',
            'Expend3' => '',
            'Expend4' => '',
            'Expend5' => '',
            'IsWx' => '7',
            'LicensePlate' => '粤AD91585',
            'Mileage' => 5000,
            'MotorSeries' => '',
            'MotorType' => '',
            'PlanArriveDate' => '2021-05-19',
            'PlanArriveTime' => '13:00-14:00',
            'RepairType' => 1,
            'Status' => 1,
            'VinCode' => 'LVM6A1G18JF072259'
        ];
        //$param = json_encode($param,JSON_UNESCAPED_UNICODE);
        $result = $client->AddRepairAppointment($param);
        dd($result);

报错如图:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空袭的梦i 2022-09-19 23:13:43

看着是没问题的. 需要打开 trace 看一下发送和请求的具体xml
我看类型说明, 参数应该是 ['data' => [ [ 数据 ], [数据] ] ] 这种结构

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文