webserver配置

client.php

 

<?php
 $a=new SoapClient("http://www.163.com/webserver/TestSoap.wsdl");
 echo $a->HelloWorld();
 echo("<br />");
 echo $a->addcon(80,80);
?>

 

myservice.php

 

<?php
class service
{
  public function HelloWorld()
  {
      return  "Helldo";
  }
  public  function addcon($a,$b)
  {
      return $a+$b;
  }
}
//TestSoap.wsd需要在后面采用Zend Studio生成。
$server=new SoapServer('TestSoap.wsdl');
$server->setClass("service");
$server->handle();
?>

 

 

testsoap.wsdl

 

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

<!-- WSDL file generated by Zend Studio. -->

<definitions name="TestSoap" targetNamespace="urn:TestSoap" xmlns:typens="urn:TestSoap" 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="addcon">
  <part name="a"/>
  <part name="b"/>
 </message>
 <message name="addconResponse">
  <part name="addconReturn"/>
 </message>
 <message name="HelloWorld"/>
 <message name="HelloWorldResponse">
  <part name="HelloWorldReturn"/>
 </message>
 <portType name="servicePortType">
  <operation name="addcon">
   <input message="typens:addcon"/>
   <output message="typens:addconResponse"/>
  </operation>
  <operation name="HelloWorld">
   <input message="typens:HelloWorld"/>
   <output message="typens:HelloWorldResponse"/>
  </operation>
 </portType>
 <binding name="serviceBinding" type="typens:servicePortType">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="addcon">
   <soap:operation soapAction="urn:serviceAction"/>
   <input>
    <soap:body namespace="urn:TestSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   </input>
   <output>
    <soap:body namespace="urn:TestSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   </output>
  </operation>
  <operation name="HelloWorld">
   <soap:operation soapAction="urn:serviceAction"/>
   <input>
    <soap:body namespace="urn:TestSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   </input>
   <output>
    <soap:body namespace="urn:TestSoap" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
   </output>
  </operation>
 </binding>
 <service name="TestSoapService">
  <port name="servicePort" binding="typens:serviceBinding">
   <soap:address location="http://www.163.com/webserver/myservice.php"/>
  </port>
 </service>
</definitions>

 

php.ini配置

打开extension=php_soap.dll

[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled=1
; Sets the directory name where SOAP extension will put cache files.
soap.wsdl_cache_dir="/tmp"
; (time to live) Sets the number of second while cached file will be used
; instead of original one.
soap.wsdl_cache_ttl=86400

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值