bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

soap怎么在PHP中使用-創(chuàng)新互聯(lián)

這篇文章給大家介紹soap怎么在PHP中使用,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。

創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站制作、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的尼木網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

PHP 使用soap有兩種方式。


一、用wsdl文件

服務(wù)器端:

<?php
class service
{
  public function HelloWorld()
   {
      return  "Hello";
   }
  public  function Add($a,$b)
   {
      return $a+$b;
   }
}
$server=new SoapServer('soap.wsdl',array('soap_version' => SOAP_1_2));
$server->setClass("service");
$server->handle();
?>


資源描述文件,可以用工具(zend studio)生成。其實(shí)就是一個(gè)xml文件。


<?xml version="1.0" encoding="UTF-8"?>


<wsdl:definitions xmlns:soap="/tupian/20230522/error.aspx xmlns:tns="http://localhost/interface/" xmlns:wsdl="/tupian/20230522/error.aspx xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="soap" targetNamespace="http://localhost/interface/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://localhost/interface/">
      <xsd:element name="HelloWorld">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="in" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="HelloWorldResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="out" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="Add">
       <xsd:complexType>
        <xsd:sequence>
         <xsd:element name="in" type="xsd:int"></xsd:element>
        </xsd:sequence>
       </xsd:complexType>
      </xsd:element>
      <xsd:element name="AddResponse">
       <xsd:complexType>
        <xsd:sequence>

         <xsd:element name="out" type="xsd:int"></xsd:element>
        </xsd:sequence>
       </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
   <wsdl:message name="AddRequest">    <wsdl:part name="a" type="xsd:int"></wsdl:part>
   <wsdl:part name="b" type="xsd:int"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="AddResponse">
   <wsdl:part name="c" type="xsd:int"></wsdl:part>
  </wsdl:message>
  <wsdl:portType name="TestSoap">     <wsdl:operation name="Add">
     <wsdl:input message="tns:AddRequest"></wsdl:input>
     <wsdl:output message="tns:AddResponse"></wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="soapSOAP" type="tns:TestSoap">
   <soap:binding
    transport="/tupian/20230522/error.aspx />
   <wsdl:operation name="Add">
    <soap:operation soapAction="http://localhost/interface/Add" />
    <wsdl:input>
     <soap:body use="literal"
      namespace="http://localhost/interface/" />
    </wsdl:input>
    <wsdl:output>
     <soap:body use="literal"
      namespace="http://localhost/interface/" />
    </wsdl:output>
   </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="TestSoap">
    <wsdl:port binding="tns:soapSOAP" name="soapSOAP">
      <soap:address location="http://localhost/interface/myservice.php"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
客戶端調(diào)用:


復(fù)制代碼 代碼如下:

<?php
$soap = new SoapClient('http://localhost/interface/soap.wsdl');
echo $soap->Add(1,2);
?>


二、不用wsdl文件

服務(wù)器端:

復(fù)制代碼 代碼如下:

<?php
class service
{
  public function HelloWorld()
   {
      return  "Hello";
   }
  public  function Add($a,$b)
   {
      return $a+$b;
   }
}
$server=new SoapServer(null,array('uri' => "abcd"));
$server->setClass("service");
$server->handle();
?>


客戶端:


復(fù)制代碼 代碼如下:

<?php
try{
 $soap = new SoapClient(null,array(
   "location" => "http://localhost/interface/soap.php",
   "uri"      => "abcd",  //資源描述符服務(wù)器和客戶端必須對(duì)應(yīng)
   "style"    => SOAP_RPC,
   "use"      => SOAP_ENCODED
      ));

 echo $soap->Add(1,2);
}catch(Exction $e){
 echo print_r($e->getMessage(),true);
}
?>

關(guān)于soap怎么在PHP中使用就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。

文章名稱:soap怎么在PHP中使用-創(chuàng)新互聯(lián)
鏈接URL:http://vcdvsql.cn/article8/ddgpip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)網(wǎng)站改版網(wǎng)站內(nèi)鏈網(wǎng)站收錄標(biāo)簽優(yōu)化小程序開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)