PHP Soap Instance

Source: Internet
Author: User
Tags documentation soap xmlns zend wsdl

server end +client end +wsdl

Statement : it's simple . !!!!!!

refer to the following :

First built Server, and then use WSDL tool to generate WSDL, I'm using it. Zend Development Environment,

in the Zde in the Tools in the WSDL Generator Wizard

The first page is the name , and output Address ( after the output directly move past on OK)

The second page is class and address , class pick up tick , URL there Tim Server The address of that file.

Third page Finish

don't forget to cuff that. WSDL past ...

Remember Server don't have output in the referenced class file . .

A total of two places to add addresses

one is WSDL the description in http://127.0.0.1/test/CulculatorServer.php

one is Client the connection in HTTP://127.0.0.1/TEST/CULCULATOR.WSD

class file

<?php

/**

* @name culculator.php

* @date Fri 12:43:40 CST 2008

* @copyright Mayong (myz)

* @author Mayong (myz)

* @link http://blog.111cn.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 12:44:04 CST 2008

* @copyright Mayong (myz)

* @author Mayong (myz)

* @link http://blog.111cn.net/mayongzhan/

 */

Include ('./culculator.php ');

$server = new SoapServer ('./culculator.wsdl ');

$server->setclass (' culculator ');

$server->handle ();

?>

Client

<?php

/**

* @name culculatorclient.php

* @date Fri 12:43:54 CST 2008

* @copyright Mayong (myz)

* @author Mayong (myz)

* @link http://blog.111cn.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.xmlsoa p.org/soap/encoding/"/>

</input>

<output>

<soap:body namespace= "Urn:math" use= encoded "encodingstyle=" Http://schemas.xmlsoa p.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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.