21,886
社区成员
发帖
与我相关
我的任务
分享
$client = new SOAPClient("http://v2.shanxitele.com/service/OutWebService?wsdl", array('uri' => "http://v2.shanxitele.com/"));
print_r($client->__getfunctions());
print_r($client->__gettypes());
Array
(
[0] => callServiceResponse callService(callService $parameters)
)
Array
(
[0] => struct callService {
string in0;
string in1;
string in2;
string in3;
}
[1] => struct callServiceResponse {
string out;
}
)
可知方法 callService 需要一个 callService 类型的结构作为参数
而 struct callService 是由 in0、in1、in2、in3 四个成员组成的
如果有定义$data = array(
'in0' => 'OAuth',
'in1' => 'fc4fa30c444400b701446c540230244e',
'in2' => '96e79218965eb72c92a549dd5a330112',
'in3' => '<?xml version="1.0" encoding="UTF-8"?><BaseInfo><servId>fc4fa30c444400b701446c540230244e</servId><platform>yixin</platform><type>base</type><redirect_uri>lcoalhost/index.php</redirect_uri></BaseInfo>'
);
则$result = $client->callService($data);
echo $result->out;
就可得到这样的结果<Result><BaseInfo><SERVID><![CDATA[fc4fa30c444400b701446c540230244e]]></SERVID><URL><![CDATA[http://open.plus.yixin.im/connect/oauth2/authorize?appid=dcb33a61567e462b9928b814200c76d6&redirect_uri=http%3A%2F%2Fv2.shanxitele.com%2F%2Fservlet%2FOAuthServlet&response_type=code&scope=snsapi_base&state=fc4fa30c444400b701446c540230244e_yixin_ff80808147b48cb30147d21ceeb34922]]></URL></BaseInfo></Result>
为什么是 $result->out 而不是其他呢?
因为 callService 返回名为 callServiceResponse 的结构,而 callServiceResponse 结构的成员只有 out 一人