Webservice-php-1 (16)

Source: Internet
Author: User
Tags soap custom name wsdl

Recently read a lot about PHP WebService information, thanks to Yan 18 sharing, helped me to build the process of the server. Take your study notes as follows, which contains notes from Yan 18.

WebService

1 Quick Learn WebService

Popular say: In a certain XML format, the method of invoking the remote server, and the server returns XML content in a certain format.
A "certain format"----SOAP (Simple Object access Protocol) is a simple protocol for exchanging information in a decentralized or distributed environment and is an XML-based co-
On.
Remote server----typically deliver messages over the HTTP protocol
Summary: Webservie = = HTTP protocol + SOAP-formatted XML

Example 1:soap request

Post/webservices/mobilecodews.asmx http/1.1
Host:webservice.webxml.com.cn
Content-type:text/xml; Charset=utf-8
content-length:354
SOAPAction: "Http://WebXml.com.cn/getMobileCodeInfo"
<?xml version= "1.0" encoding= "Utf-8"?>
<soap:envelope xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd= "http://www.w3.org/2001/ XmlSchema "xmlns:soap=" Http://WebXml.com.cn/getMobileCodeInfo >

2 PHP Client Request WebService

Modify PHP.ini
Extension=php_soap.dll before the ";" Remove.
Restart Apache
The PHP SoapClient class can be used to request WebService

new soapclient ('http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx? WSDL');p rint_r ($soap->getmobilecodeinfo ('mobilecode' ='13**********'));
Array ([0] =getmobilecodeinforesponse getmobilecodeinfo (getmobilecodeinfo $parameters) [1] =getdatabaseinforesponse getdatabaseinfo (getdatabaseinfo $parameters)) Array ([0] =structGetmobilecodeinfo {stringMobilecode;stringUserID;} [1] =structGetmobilecodeinforesponse {stringGetmobilecodeinforesult;} [2] =structGetDatabaseInfo {}[3] =structgetdatabaseinforesponse {arrayofstring getdatabaseinforesult;} [4] =structarrayofstring {

string string;
}

// Call Method Print_r ($soap->getmobilecodeinfo ('mobilecode' = ' 13426060134 ') ) );

return results

13*********: Beijing Beijing Beijing Mobile Dynamic Zone card)

3 Building WebService Server

What is WSDL?
WSDL is the specification of WebService.

<?xml Version ='1.0'encoding ='UTF-8'? ><definitions name='custom name [optional]'targetnamespace='namespace [general URL]'Xmlns:tns='namespace [value Same as targetnamespace]'Xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'xmlns:xsd='Http://www.w3.org/2001/XMLSchema'Xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'xmlns='http://schemas.xmlsoap.org/wsdl/'><!--<types> elements define the data types used by the Web service, WSDL uses XML Schema syntax to define the data type, or you can customize the types that the schema does not contain--><types> <xsd:schema xmlns:xsd="Http://www.w3.org/2001/XMLSchema"targetnamespace="[Value ditto TNS]"></xsd:schema></types><!--<message>element to define the part of each message, and the associated data type.--><message name='Operation name Request'><part name=" Term"Type="xsd:string"/></message><message name='Action Name Response'><part name="value"Type="xsd:string"/></message><!--<portType>The element is the most important WSDL element. It describes a Web service, the operations that can be performed, and the associated messages. It tells you which WebService connection point to play and plays a controller.--><porttype name='Action list name'><operation name='Action name'><input message='TNS: Operation name Request'/><output message='TNS: Action name Response'/></operation></porttype><!--<binding> elements Define message format and protocol details for each port--><binding name='channel name under WS'Type='TNS: List of actions under channel'><!--Style: attribute desirable value"RPC"Or"Document"A Ransport: property defines the SOAP protocol to use. In this example we use http--><soap:binding style='RPC'Transport='http://schemas.xmlsoap.org/soap/http'/><!--The operation element defines the operators provided for each port, and for each operation, the corresponding SOAP behavior needs to be defined--><operation name='Test'><soap:operation soapaction='http://www.cwtservice.cn/newOperation/'/><input><soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'Encodingstyle='http://schemas.xmlsoap.org/soap/encoding/'/></input><output><soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'Encodingstyle='http://schemas.xmlsoap.org/soap/encoding/'/></output></operation></binding><!--<service> contains one or more port elements, Each port element represents a different Web service--><service name='WebService name [e.g. WEATHERWS,SHOPWS]'><port name='channel name under WS [E.G. CARTSOAP, shopping cart service]'binding='tns:[channel name, same left]'><soap:address location='Http://[webservice Address]'/></port></service></definitions>

Webservice-php-1 (16)

Related Article

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.