zoukankan      html  css  js  c++  java
  • PHP笔记——SOAP

    SOAP简单的理解,就是这样的一个开放协议SOAP=RPC+HTTP+XML:采用HTTP作为底层通讯协议;RPC作为一致性的调用途径,XML作为数据传送的格式,允许服务提供者和服务客户经过防火墙在INTERNET进行通讯交互。RPC的描叙可能不大准确,因为SOAP一开始构思就是要实现平台与环境的无关性和独立性,每一个通过网络的远程调用都可以通过SOAP封装起来,包括DCE(Distributed Computing Environment ) RPC CALLS,COM/DCOM CALLS, CORBA CALLS, JAVA CALLS,etc。

    SOAP 使用 HTTP 传送 XML,尽管HTTP 不是有效率的通讯协议,而且 XML 还需要额外的文件解析(parse),两者使得交易的速度大大低于其它方案。但是XML 是一个开放、健全、有语义的讯息机制,而 HTTP 是一个广泛又能避免许多关于防火墙的问题,从而使SOAP得到了广泛的应用。但是如果效率对你来说很重要,那么你应该多考虑其它的方式,而不要用 SOAP。

     

    soap 的优点是 可以传递结构化的 数据,而前两种不行。
    btw, soap 最终也是使用 HTTP 传送 XML

    operation  函数

    oprttype

    element  元素

    message 元素集合

    <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:tm
    ="http://microsoft.com/wsdl/mime/textMatching/"
    xmlns:soapenc
    ="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:mime
    ="http://schemas.xmlsoap.org/wsdl/mime/"

    xmlns:s
    ="http://www.w3.org/2001/XMLSchema"
    xmlns:soap12
    ="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:http
    ="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:wsdl
    ="http://schemas.xmlsoap.org/wsdl/"
    targetNamespace
    ="http://www.webserviceX.NET" <!--自定义-->
    xmlns:tns="http://www.webserviceX.NET" > <!--tns—“this namespace”的缩写,包含被定义服务的主名称空间-->
    <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET">
    <s:element name="GetWeather"> <!--传入参数的集合-->
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="CityName" type="s:string"/><!--minOccurs 和 maxOccurs 属性限制指定的实体可以连续出现在 XML 实例文档中的对应位置的次数。-->
    <s:element minOccurs="0" maxOccurs="1" name="CountryName" type="s:string"/>
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:element name="GetWeatherResponse"> <!--函数返回值的类型-->
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="GetWeatherResult" type="s:string"/>
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:element name="string" nillable="true" type="s:string"/>
    </s:schema>
    </wsdl:types>
    <wsdl:message name="GetWeatherSoapIn"><!--函数的参数在此处定义,前面的都是在声明变量的类型,例如GetWeather就是一个结构体,包含字符串CityName和CountryName-->
    <wsdl:part name="parameters" element="tns:GetWeather"/><!--函数要传入的参数,是类型为GetWeather的parameters参数-->
    </wsdl:message>
    <wsdl:message name="GetWeatherSoapOut">
    <wsdl:part name="parameters" element="tns:GetWeatherResponse"/>
    </wsdl:message>
    <wsdl:portType name="GlobalWeatherSoap"><!--这个节点用来定义上面的参数的函数以及传入的参数和返回类型-->
    <wsdl:operation name="GetWeather"><!--函数名为GetWeather-->
    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    Get weather report for all major cities around the world.
    </wsdl:documentation>
    <wsdl:input message="tns:GetWeatherSoapIn"/><!--GetWeatherSoapIn标签中的parameters为传入参数-->
    <wsdl:output message="tns:GetWeatherSoapOut"/><!--GetWeatherSoapOut标签中的parameters为返回类型-->
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="GlobalWeatherSoap" type="tns:GlobalWeatherSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="GetWeather">
    <soap:operation soapAction="http://www.webserviceX.NET/GetWeather" style="document"/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="GetCitiesByCountry">
    <soap:operation soapAction="http://localhost/GetCitiesByCountry" style="document"/>
    <wsdl:input>
    <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="GlobalWeather">
    <wsdl:port name="GlobalWeatherSoap" binding="tns:GlobalWeatherSoap">
    <soap:address location="http://localhost/phpmyadmin/ws/TestWebService.php"/>//这里写自己的webservice发布到网上的url
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>



  • 相关阅读:
    github提交代码——步骤备忘
    springboot 集成 lombok.jar
    maven 内置pom属性
    对spring的IOC和aop的学习总结
    前端表单form提交验证清除
    Graph and Chart Study
    Xml学习笔记
    转载unity编辑器xml数据库插件
    MySql(二)_NHibernateHelper管理会话工厂
    MySql(一)_利用NHibernate和MySql交互
  • 原文地址:https://www.cnblogs.com/bugY/p/2205242.html
Copyright © 2011-2022 走看看