简体   繁体   中英

How to create an object from the WSDL of a SOAP WebService in PHP?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM