


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

AI Hentai Generator
Generate AI Hentai for free.

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



This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.
