[英]How to create an object from the WSDL of a SOAP WebService in PHP?
I am trying to call a Webservice with PHP. 我试图用PHP调用Webservice。 It works fine, but I got one function, which throws an
NullReferenceException
. 它工作正常,但我有一个函数,它抛出一个
NullReferenceException
。 The function parameters are classes of the Webservice and defined in the WSDL file. 函数参数是Webservice的类,并在WSDL文件中定义。 In C# I can create instances of these classes, then I can pass these with the method.
在C#中,我可以创建这些类的实例,然后我可以使用该方法传递这些类。 This works like expected, but in PHP I can't create these instances of the class like in C#.
这可以像预期的那样工作,但在PHP中,我无法像在C#中那样创建类的这些实例。
I tried to create an instance of the class form the WSDL: 我试图从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. 当我尝试用这些参数调用我的函数时,我仍然收到
NullReferenceException
错误。
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?
有没有人有想法,如何解决这个问题?
I solved it by generating php classes from the WSDL file. 我通过从WSDL文件生成php类来解决它。 For this I used the tool wsdl2phpgenerator .
为此,我使用了工具wsdl2phpgenerator 。
After I passed the values as class objects, it worked. 我将值作为类对象传递后,它工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.