日期:2014-05-20  浏览次数:20582 次

java怎么调用php soap建立的webservice
本帖最后由 iszhang2012 于 2012-11-27 11:59:44 编辑
php服务端使用soap扩展

<?php

$soap = new SoapServer(null,array('uri'=>"http://www.test.com/"));
$soap->addFunction('minus_func');
$soap->addFunction('hello');
$soap->addFunction(SOAP_FUNCTIONS_ALL);
$soap->handle();

function minus_func($i, $j)
{
$res = $i - $j; 
return $res;
}


function hello()
{
$date=array(
get_response=>array(
'user'=>'zhangsan',
'pass'=>'123456',
'msg'=>'user and pass is right',
'code'=>'10'
)
);
return json_encode($date);
}


?>


php客户端

<?php  
    try {  
        $client = new SoapClient(null,  
            array(  
                'location' =>"http://www.test.com/webservice.php",  
                'uri' => "http://192.168.1.102/"  
            )  
        );  
//        echo $client->minus_func(34,30);  
         echo $client->hello(); 
      
    } catch (SoapFault $fault){  
        echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;  
    }  
?> 





java 怎么调用php做的webservice呢








------解决方案--------------------
这个还真不知道。
------解决方案--------------------
HttpURLConnection get或者post请求就可以了~
另外看要报文是用XML还是JSON来传送的~你要做的只是请求完以后解析他们
------解决方案--------------------
楼上的,cmnet cmwap下试过吗?