php的nosoap和java jws的soap通讯代码
1/环境介绍
客户端:php语言,采用nosoap类库调用soap接口
服务器端:java语言,采用 jws webservice 启动服务
2/示例代码
$client = new soapclient('http://192.168.11.119:8080/prm/webservice/PRMService?wsdl', false); $err = $client->getError(); if ($err) { echo 'Constructor error<pre class="prettyprint linenums" >' . $err . '
‘;
}
$client->soap_defencoding = ‘UTF-8’;
$client->decode_utf8 = false;
$data = array(‘passWord’=>’111111′,’userCode’=>’admin’,’userId’=>’0001′);
$result = $client->call(‘Action’,array(‘arg0’=>json_encode($data)));
if ($client->fault) {
echo ‘
Fault
'; print_r($result); echo '
‘;
} else {
$err = $client->getError();
if ($err) {
echo ‘Error
' . $err . '
‘;
} else {
echo ‘Result
'; print_r($result); echo '
‘;
}
}