PHP中调用Java的代码
2011-03-24 17:35
267 查看
我的项目前期用CakePHP开发了一个前台的网站,现在需要在PHP中直接访问Nutch的API接口,很是头痛,这几天一直在调研和Demo。
其实都是前人已经做过的事情,我只是把他们整合起来。
第一步,需要利用JAX-WS架设一个Web服务,参见IBM的一篇文章
第二步,写了一个PHP的Demo程序,如下:
其中$p是一个参数数组,里面的参数名称arg0需要和OrderProcess_schema1.xsd中的名称保持一致。
其实都是前人已经做过的事情,我只是把他们整合起来。
第一步,需要利用JAX-WS架设一个Web服务,参见IBM的一篇文章
第二步,写了一个PHP的Demo程序,如下:
<?php // DON'T CACHE the SOAP on the PHP server $ini = ini_set("soap.wsdl_cache_enabled","0"); $client = new SoapClient("http://localhost:8080/OrderProcessWeb/orderprocess?wsdl", array("user_agent"=>"some_string")); //your parameter to send $p = array('arg0' => 'hello world, this is royal'); //the soap function might require nested type try{ $ret = $client->processOrder($p); print json_encode($ret); //or var_dump($ret); print "<pre>"; var_dump($client->__getFunctions()); var_dump($client->__getTypes()); } catch (SoapFault $exception) { print 'SOAP Error '; print json_encode($exception); //or var_dump($exception); } ?>
其中$p是一个参数数组,里面的参数名称arg0需要和OrderProcess_schema1.xsd中的名称保持一致。
相关文章推荐
- eoLinker-API_Shop_短信服务接口-调用示例代码,支持PHP、Python、Java等语言
- Java调用PHP 代码 实例
- PHP调用java类的两种方法
- 调用发送短信 Monxin专用(PHP代码函数)
- Atitit 通过调用gui接口杀掉360杀毒 360卫士 qq保镖等难以结束的进程(javac# php )
- Android JNI中C和JAVA代码之间的互相调用
- smarty 执行php代码 调用php函数 违背smarty但不失灵活
- PHP实现Webservice的实例代码调用教程
- Android-NDK开发之基础--Android JNI实例代码(一)-- 在JNI中执行Java方法--C/C++调用Java
- Node调用Java的示例代码
- oracle实现存储过程的分页并用java代码调用存储过程
- Atitit java c# php c++ js跨语言调用matlab实现边缘检测等功能attilax总结
- Java静态代码块(static block)调用陷阱小记
- Unity3D研究院之打开Activity与调用JAVA代码传递参数
- jni-使用c代码调用java文件
- (JNI)c代码利用反射调用java方法
- php调用java的完整安装配置说明文档
- axis2 webservice入门知识(JS,Java,PHP调用实例源码)
- JNA:JAVA调用DLL 超详细代码实战
- java调用matlab代码方法[matlab version 2010a]