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 根据会员信息表绘制堆积柱状图
  • ¥100 华为手机私有App后台保活
  • ¥15 sqlserver中加密的密码字段查询问题
  • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
  • ¥20 我的这个coe文件到底哪儿出问题了
  • ¥15 matlab使用自定义函数时一直报错输入参数过多
  • ¥15 设计一个温度闭环控制系统
  • ¥100 rtmpose姿态评估
  • ¥15 通联支付网上收银统一下单接口
  • ¥15 angular有偿编写,