douhu7807 2019-03-25 12:41
浏览 117
已采纳

如何在PHP中使用SOAP WebService的WSDL创建对象?

I am trying to call a Webservice with PHP. It works fine, but I got one function, which throws an NullReferenceException. The function parameters are classes of the Webservice and defined in the WSDL file. In C# I can create instances of these classes, then I can pass these with the method. This works like expected, but in PHP I can't create these instances of the class like in C#.

I tried to create an instance of the class form the WSDL:

$myinstance1 = new SoapVar($content, SOAP_ENC_OBJECT, "Class1Name", $url_WSDL);
$myinstance2 = new SoapVar($content, SOAP_ENC_OBJECT, "Class2Name", $url_WSDL);

and then i tried to call the method with these parameters:

$result = $soapclient->GetMyObjects($myinstance1, $myinstance2);

I guess one problem is, that one of the classes is of type enumeration. The other class is a type of integer array. When I try to call my functions with these parameters I still recieve the NullReferenceException error.

I think the problem is because of the enum type, which isn't converted correctly. Did I instanciate correctly? Does anyone have an idea, how to fix this problem?

  • 写回答

1条回答 默认 最新

  • douzhicai7148 2019-05-08 12:17
    关注

    I solved it by generating php classes from the WSDL file. For this I used the tool wsdl2phpgenerator.
    After I passed the values ​​as class objects, it worked.

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

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵