A period of time to do a project two development, there is a function is required to PHP call Java implementation of the WebService interface, and pass some parameters to the interface, and then follow the interface provided by the other side of the document to make a parameter call, Java side has received the request, but the parameter is always NULL, Some of the code is as follows:
1 $client=NewSoapClient ($this-WebServiceURL); 2 $client->soap_defencoding = ' Utf-8 ';3 $client->xml_encoding = ' Utf-8 ';4 $param=$context;//parameter stitching XML string5 $result=$client->managementmemberinfo ($param);//return value
No matter what type of data is passed, the other person receives null. Then all kinds of Baidu (here are spit groove: Baidu really spicy chicken. ), Baidu came out of various messy answers, various attempts, and then continued various failures. [Email protected] .... You'll see an article later that says to add a key value and then try it:
1 $client = new soapclient ( $this ->webserviceurl); 2 $client ->soap_defencoding = ' Utf-8 ' 3 $client ->xml_encoding = ' utf-8 ' ; 4 $param = array (' context ' = $context ); // parameter stitching XML string 5 $result = $client ->managementmemberinfo ( $param ); // return value
Then, it's still a tragedy ... Continue Baidu, Bing ... Then saw an article said to add the key value, the key named arg0 this, if there are multiple should be an analogy arg1,arg2 and so on, well, originally I think with the front add key value no difference, but still tried:
$client New SoapClient ($this$client->soap_defencoding = ' utf-8 '; $client->xml_encoding = ' utf-8 '; $param Array (' arg0 ' =$context); // parameter stitching XML string $result $client->managementmemberinfo ($param); // return value
Then, the other person said to receive the data ...
I hereby record it. PS: For why must be arg0 not too understand, if have clear, hope to small white pointing, thank you.
PHP calls WebService interface, Java code cannot receive parameters