


php5 apache 2.2 webservice creation and configuration (java)_PHP tutorial
php 5 apache 2.2 webservice creation and configuration
Test tool: wsCaller.jar (this article is for webservice called by java program)
Tip: To run wsCaller.jar, you must choose to install jdk. If jdk is not installed, then wsCaller.jar It will be displayed in the form of a compressed package
1 The interface used to write webservice
class service
{
function add($a,$b){
$c=$a+$b;
return $c;
}
function str($string){
return $string;
}
}
//require('cls_mysql.php');
//$db = new cls_mysql('localhost', 'root', 'root', test_db');
//$db = new cls_mysql('211.103.156.227:3306', 'root', 'txtx', test_db') ;
//'testwsdl.wsd needs to be generated later using Zend Studio.
$server=new SoapServer('testwsdl.wsdl',array('uri' => 'http://webserver.com/','encoding'=>'utf-8','soap_version' = > SOAP_1_2 ));
$server->setClass("service");
$server->handle();
?>
2.生成wsdl文件
菜单中
File--àExport---àphp 选中 “wsdl file” 然后下一步 (图1)
File name 是wsdl 文件所在的位置
Exported files 下面的文件是你上面刚刚创建的php文件(接口文件)
Classes 下面的service 前面的勾要打上
URL 中填写接口文件的访问地址 (如:http://webserver.com/rpcservice.php)
点击global settings 出现下图(图3)
选择RPC – Oriented
然后点击 “ok” 在点击 “Finish”
出现下图(图4)
最后一步就是给 每个参数一个合理的类型(下图)
然后保存
到此 wsdl文件已经生成
访问路径 http://webserver.com/testwsdl.wsdl (会出现下面内容)
如果不出现 则要配置apache 使其支持xml
注: 不要用chrome 打开wsdl文件 ,可能会显示不正常 (可以用ie firfox)
测试是否可以成功调用
测试工具
wsCaller.jar
注:必需安装JDK 才能运行wsCaller.jar 请不要解压wsCaller.jar
如果不能正确返回信息 可直接访问你的php 看看会不会报错
(本例http://webserver.com/rpcservice.php)
Php 要支持 soap
如果php 版本是5.X 则 编辑 php.ini
extension=php_soap.dll (添加 如果存在则去掉注释)
重启一下apache
apache 要注意这个文件 mime.types
函数添加新参数
找到message name=”函数名” 中直接复制一下并把参数改一下参数名
WSDL文件
Php接口文件
1 |
function add( $a , $b , $e ){
|
2 |
$c = $a + $b + $e ;
|
3 |
return $c ;
|
4 |
} |
注:$e 就是wsdl文件中的 c 参数
添加新的函数
WSDL复制代码就行; PHP写出对应的函数 (看一下选中的部分 其实就是复制了一下add 这个函数 并且直接粘贴在它下面就可以) 下面以 添加add_bak 函数为例
WSDL
1.复制message 标签
2.复制 portType 中的标签
3.Copybinding Tag content
PHP
function add_bak($a,$b,$e){
$c=$a+$b-$e;
return $c;
}
Test results
add_bak function
add function
Other functions have not been tested one by one and screenshots
If there is something wrong, please point it out. Thank you

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.
