Copyright statement: original works can be reproduced. During reprinting, you must mark the original publication, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://blog.csdn.net/mayongzhan-ma yongzhan, myz, mayongzhan
SERVER + client + WSDL
Statement: Very simple !!!!!!
Refer to the following:
Http://blog.csdn.net/phphot/archive/2007/07/15/1692109.aspx
Create the server first, and then use the WSDL tool to generate the WSDL. I use Zend development environment,
In tools in zde, the WSDL generator wizard
The first page is the name, and the output address (after the output is moved directly, OK)
The second page is the class and address. The class is checked, and the URL adds the address of the Server File.
Page 3 finish
Don't forget to copy the WSDL...
Remember that no output exists in the class file referenced by the server.
There are two addresses to be added.
One is the description http: // 127.0.0.1/test/culculatorserver. php In WSDL.
One is the connection http: // 127.0.0.1/test/culculator. WSD in the client.
Class File
<? PHP
/**
* @ Name culculator. php
* @ Date Fri Jan 25 12:43:40 CST 2008
* @ Copyright Ma yongzhan (myz)
* @ Author ma yongzhan (myz)
* @ Link http://blog.csdn.net/mayongzhan/
*/
Class culculator
{
/**
* Sum
*
* @ Param float $ x
* @ Param float $ y
* @ Return float
*/
Public Function add ($ X, $ Y)
{
Return $ x + $ Y;
}
}
?>
Server
<? PHP
/**
* @ Name culculatorserver. php
* @ Date Fri Jan 25 12:44:04 CST 2008
* @ Copyright Ma yongzhan (myz)
* @ Author ma yongzhan (myz)
* @ Link http://blog.csdn.net/mayongzhan/
*/
Include ('./culator. php ');
$ Server = new soapserver ('./culculator. WSDL ');
$ Server-> setclass ('culator ');
$ Server-> handle ();
?>
Client
<? PHP
/**
* @ Name culculatorclient. php
* @ Date Fri Jan 25 12:43:54 CST 2008
* @ Copyright Ma yongzhan (myz)
* @ Author ma yongzhan (myz)
* @ Link http://blog.csdn.net/mayongzhan/
*/
$ Soap = new soapclient ('HTTP: // 127.0.0.1/test/culculator. WSDL ');
Echo $ soap-> Add (1, 2 );
?>
WSDL
<? XML version = '1. 0' encoding = 'utf-8'?>
<! -- WSDL file generated by Zend studio. -->
<Definitions name = "math" targetnamespace = "urn: math" xmlns: typens = "urn: math" xmlns: XSD = "http://www.w3.org/2001/XMLSchema" xmlns: Soap = "http://schemas.xmlsoap.org/wsdl/soap/" xmlns: soapenc = "http://schemas.xmlsoap.org/soap/encoding/" xmlns: WSDL = "http://schemas.xmlsoap.org/wsdl/" xmlns = "http://schemas.xmlsoap.org/wsdl/">
<Message name = "add">
<Part name = "X" type = "XSD: float"/>
<Part name = "Y" type = "XSD: float"/>
</Message>
<Message name = "addresponse">
<Part name = "addreturn" type = "XSD: float"/>
</Message>
<Porttype name = "culculatorporttype">
<Operation name = "add">
<Documentation>
Sum
</Documentation>
<Input message = "typens: Add"/>
<Output Message = "typens: addresponse"/>
</Operation>
</Porttype>
<Binding name = "culculatorbinding" type = "typens: culculatorporttype">
<Soap: Binding style = "RPC" Transport = "http://schemas.xmlsoap.org/soap/http"/>
<Operation name = "add">
<Soap: Operation soapaction = "urn: culculatoraction"/>
<Input>
<Soap: Body namespace = "urn: math" use = "encoded" encodingstyle = "http://schemas.xmlsoap.org/soap/encoding/"/>
</Input>
<Output>
<Soap: Body namespace = "urn: math" use = "encoded" encodingstyle = "http://schemas.xmlsoap.org/soap/encoding/"/>
</Output>
</Operation>
</Binding>
<Service name = "mathservice">
<Port name = "culculatorport" binding = "typens: culculatorbinding">
<Soap: address location = "http: // 127.0.0.1/test/culculatorserver. php"/>
</Port>
</Service>
</Definitions>