①首先我们写一个简单的java类并发布webservice.
package com.php;
import java.util.Map;
/**
* @author yangjuqi
*
*/
public class WebServiceImpl {
public String sendTransact(Map map) throws Exception {
System.out.println("::: Call testModel1 :::");
if(map!=null){
String bugmanifestid = StringUtil.getValue(map.get("bugmanifestid"));
String editedby = StringUtil.getValue(map.get("editedby"));
String dditeddate = StringUtil.getValue(map.get("dditeddate"));
String fullinfo = StringUtil.getValue(map.get("fullinfo"));
String action = StringUtil.getValue(map.get("action"));
System.out.println("bugmanifestid -$amp;quot;$ +bugmanifestid);
System.out.println("editedby -$amp;quot;$ +editedby);
System.out.println("dditeddate -$amp;quot;$ +dditeddate);
System.out.println("fullinfo -$amp;quot;$ +fullinfo);
System.out.println("action -$amp;quot;$ +action);
}
return "success";
deployment xmlns=""
xmlns:java=""
handler name="URLMapper"
type="java:org.apache.axis.handlers.http.URLMapper" /
handler name="auth"
type="java:com.php.AuthenticationHandler" /
handler name="URLLogging"
type="java:com.php.LogHandler"
parameter name="filename" value="c:\\MyService.log" /
/handler
service name="IWebService" provider="java:RPC"
parameter name="className"
value="com.php.WebServiceImpl" /
parameter name="allowedMethods" value="*" /
namespace;/namespace
/service
transport name="http"
requestFlow
handler type="URLMapper" /
handler type="URLLogging" /
/requestFlow
/transport
/deployment
php
/*
* @author juqi yang $amp;amp;$gt;
echo " ::: PHP CALL JAVA-WEBSERVICE ::: br$amp;quot;$;
require_once("nusoap/lib/nusoap.php");
// 要访问的webservice路径
$NusoapWSDL=" wsdl";
$client = new soapclient($NusoapWSDL, true);
// 设置参数(注意:PHP只能以'数组集'方式传递参数,如果服务端是java,用Map接收)
'editedby' = '张三',
'fullinfo' = '已联系刘德华,筹备今晚吃饭的事,等待回复',
'action' = '0');
echo "begin remote ...br$amp;quot;$;
// 调用远程方法
$result = $client-call('sendTransact', array($param));
echo "end remote ...br$amp;quot;$;
// 显示执行结果
if (!$err=$client-getError()){
echo '结果 : '.$result;
}else{
echo '错误 : '.$err;
php页面显示:
::: PHP CALL JAVA-WEBSERVICE :::
begin remote ...
end remote ...
结果 : success
jboss后台监视结果:
①编写php webservice
function sendManifest($param)
{
//把接收到的数据显示出来
return "hello ".$param["projectid"]."=$amp;quot;$.$param["projectname"]."=$amp;quot;$.$param["moduleid"];
$server = new nusoap_server();
//配置WSDL namespace
$server-configureWSDL('myservice', //服务名称
'', //tns指定的namespace,一般填写自己的URI
true, //endpoint url or false
'rpc', //服务样式
'', //传输协议,一直是这个.
'' //wsdl 'types'元素targetNamespace
);
// 注册web服务
$server-register('sendManifest', // 服务
array(
'projectid' = 'xsd:string',
'projectname' = 'xsd:string',
'moduleid' = 'xsd:string',
'modulepath' = 'xsd:string',
'bugtitle' = 'xsd:string',
'bugtype' = 'xsd:string',
'openedby' = 'xsd:string',
'openeddate' = 'xsd:string',
'assignedto' = 'xsd:string',
'assigneddate' = 'xsd:string',
'fixedtime' = 'xsd:string',
'fullinfo' = 'xsd:string',
'bugmanifestid' = 'xsd:string'), // 输入参数;数组,指定类型
array('resultCode' = 'xsd:string'), // 输出;数组,指定类型
'', // namespace of method
'', // soapaction
'rpc', // style
'encoded', // use
'serviceConsumeNotify' // documentation
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) $HTTP_RAW_POST_DATA : '';
$server-service($HTTP_RAW_POST_DATA);
import java.util.HashMap;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class CallPhpServer {
* 测试方法
* @return
* @throws Exception
public static String callManifest() throws Exception {
System.out.println("0");
Service service = new Service();
Call call = (Call) service.createCall();
System.out.println("1");
call.setTargetEndpointAddress(new java.net.URL(""));
call.setOperationName("sendManifest");
Map map=new HashMap();
map.put("moduleid", "11");
map.put("bugtype", "TrackThings");
map.put("openedby", "zhangsan");
map.put("assignedto", "liumang");
call.addParameter("param", org.apache.axis.Constants.SOAP_ARRAY,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);
Object obj=call.invoke(new Object[]{map});
return obj.toString();
public static void main(String[] args) throws Exception {
System.out.println("::: call php webservice :::");
String str = callManifest();
System.out.println(result);
控制台显示结果:
::: call php webservice :::
PHP开发的都高效,如果特别在意效率,就不要用框架,自己写代码.
WinBinder 是一种开源的 PHP 动态扩展(.dll) ,也算是脚本编程语言,为php 在window 下的开发提供用户界面UI ,它负责调用window 的API 接口.其运行 PHP 程序员轻松地使用 PHP 创建 Windows 应用程序.当然,这个只能在 Windows 下运行.本身是一个软件,php 程序员可以通过这个软件开发界面.官方网站说得很不错,无须编译php. 只要保存文件扩展为.phpw ,然后用 php.exe 打开就可以运行.具体开发感受如何,要试验一下才知道.初步感觉不会比php-gtk 差.
extension=php_winbinder.dll
然后到打开命令行(cmd ),进入到 winbinder_xxx\Code\Samples 目录下,运行:
C:phpcliphp.exe manytests_main.phpw
这样就可以看到 Windows 窗口了,测试用的例子很多,可以都试试.我试了一下中文,还是支持得不错的,想想也是,WinBinder 是通过扩展的方式,加载到 PHP 中,其调用的都是 Windows 的 APIs .实际上可以将 WinBinder 分为两层,一层是底层,叫 API 层,作为 PHP 扩展直接连接 Windows 的 API ,并为第二层(高层,叫 PHP 层)提供统一的调用接口.
你以为php只能做桌面应用?错移动应用也照样拿下.PHP for Android让你用你最熟悉的php开发android软件.
以上就是土嘎嘎小编大虾米为大家整理的相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!