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.

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

报告相同问题?

悬赏问题

  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签)
  • ¥50 sft下载大文阻塞卡死
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题