此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【shyrobin】截止到2008-07-03 16:07:33的历史汇总数据(不包括此帖):
发帖的总数量:3                        发帖的总分数:120                      
结贴的总数量:1                        结贴的总分数:20                       
无满意结贴数:0                        无满意结贴分:0                        
未结的帖子数:2                        未结的总分数:100                      
结贴的百分比:33.33 %               结分的百分比:16.67 %                  
无满意结贴率:0.00  %               无满意结分率:0.00  %                  
楼主该结一些帖子了

解决方案 »

  1.   

    去看看《PHP 和mysql web开发》第三版33章1.开发包里有一个SmWSImpl.wsdl 文件,我不明白是不是让我先用这个文件建立一个server,然后再建立客户端调用?还是说这个文件仅仅只是参考,实际要远程调用联通的webserver?
    ——————————
    当然是让你开发的客户端调用,服务器端人家处理好了2.如果需要建立一个server ,那么怎么发布? 还是说只需要将server的文件写好,客户端指定到它的路径就行了?
    如果是你自已的server,根据用户请求,调用web服务数据后输出
    ——————————————————
    如果联通的server,不知道如何处理的,但觉得和网页处理一样吧(只不过要用xml定义相关协议)
      

  2.   

    1、先写好你要发布的SOAP接口程序(一般是一个类);先保证这个类能运行正常;
    2、生成把这个类对应的WSDL文件,我用ZEND编辑器(工具->WSDL generator..的选项,按提示操作就行),也可用其它工具生成;
    3、写服务器程序(就是发布你接口方法,供客户端调用);
    <?phprequire( '你的类文件');
    $fwsdl = '你生成的WSDL文件';
    try{
    $server = new SoapServer($fwsdl);
    $server->setClass("类名");
    $server->handle();
    }catch(Exception $e){
    var_dump($e->message());
    }
    ?>
    这是最简单的一个例子,并且这个类不包含构造函数,如果包含构造函数自已看手册吧。4、写一个客户端测试;
    <?
    // web service描述文件
    $fwsdl = "访问WSDL文件的URL";
    如:$fwsdl = "http://域名/hnetv.wsdl";try {
        $client = new SoapClient($fwsdl);
        $result = $client->类中定义的方法(参数);
    } catch (Exception $e) {
        var_dump($e->getMessage());
    }
    能正确获取数据就表示成功了!!
      

  3.   

    谢谢3楼兄弟
    如果说让我客户端调用,但它的SmWSImpl.wsdl最下面的地址 却是指向本地的8080端口...
      

  4.   

    4楼的兄弟 谢谢你的例子
    如果联通提供了这个 wsdl 那么我是不是不用建立服务器端 直接调用就可以了?
      

  5.   

    问题还没解决 高手继续帮忙啊~~
    上面这个例子 我用zend不能生成wsdl文件 老是一点WSDL generator.. 就死掉了 系统vista
    然后在网上找了个现成的例子
    Culculator.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>
                                求和
                         </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.xmlsoap.org/soap/encoding/"/>
                         </input>
                         <output>
                                <soap:body namespace="urn:math" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
                         </output>
                  </operation>
           </binding>
           <service name="mathService">
                  <port name="CulculatorPort" binding="typens:CulculatorBinding">
                         <soap:address location="http://localhost/test/SOAP/CulculatorServer.php"/>
                  </port>
           </service>
    </definitions>Server.php文件
    <?php
    include("./Culculator.php");
    $server = new SoapServer("./Culculator.wsdl"); 
    $server->setClass("Culculator");
    $server->handle(); 
    ?>Client.php文件
    <?php 
    $soap = new SoapClient("http://127.0.0.1/test/SOAP/Culculator.wsdl"); 
    echo $soap->add(1, 2);
    ?>Culculator.php文件
    <?php
    class Culculator{
     public function add($x, $y){
      return $x + $y;
     }
    }
    ?>但是执行后报错
    Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in D:\xampp\htdocs\test\SOAP\Client.php:11 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://localhos...', 'urn:CulculatorA...', 1, 0) #1 [internal function]: SoapClient->__call('add', Array) #2 D:\xampp\htdocs\test\SOAP\Client.php(11): SoapClient->add(1, 2) #3 {main} thrown in D:\xampp\htdocs\test\SOAP\Client.php on line 11
      

  6.   

    联通的短信接口没做过,不过我开发Web Service时就是直接看手册实现的。
      

  7.   

    昨天看了一下相关例子
    wsdl服务调用看见wsdl客户端是这样调用的连接web服务的http://127.0.0.1/test/SOAP/Culculator.wsdl"
    如果web服务在你自已的电脑上,就可以调用上面的,如果在联通网上,则连接连通的第二步,生成一个代理,用这个代理调用web服务的接口,相当于用web服务的wsdl生成一对象
    相当于实例化一个远程的类。第三步:有这个代理去和web服务交互
      

  8.   

    另外,我觉得联通给你的wsdl文档可能是既可用于客户端调用,也可以生成web服务的
    如果你要高用联通的服务,可以只用客户端文档就可以了
    你可咨询联通相关人员一下
      

  9.   

    但是执行后报错 
    Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in D:\xampp\htdocs\test\SOAP\Client.php:11 Stack trace: #0 [internal function]: SoapClient->__doRequest(' <?xml version="...', 'http://localhos...', 'urn:CulculatorA...', 1, 0) #1 [internal function]: SoapClient->__call('add', Array) #2 D:\xampp\htdocs\test\SOAP\Client.php(11): SoapClient->add(1, 2) #3 {main} thrown in D:\xampp\htdocs\test\SOAP\Client.php on line 11原因是客户端请求失败;<soap:address location="http://localhost/test/SOAP/CulculatorServer.php"/> 
    注意红色的文件名,按你的描述在你的环境应该是Server.php;服务端都有问题,客户端请求当然会失败!
    另外你最好先运行服务端程序,先排除服务端的问题;生在WSDL文件失败可能是系统的原因,我在xp下没有问题!呵呵
      

  10.   

    如果是和.net平台交互,方法要加上规范的方法描术如下!
    另外.net平台给我返回值类型可以是对象,反之我没有做成功过,有做过的兄弟给大家共享一下,谢了;         /**
     * Enter description here...
     *
     * @param string $a
     * @param string $b
     * @return string
     */
    public function test($a, $b)
    {
                ...........
            }
      

  11.   

    谢谢楼上热心回帖,联通http://220.196.21.3/
    是他们的网址 但是这个IP下并没有wsdl文件
      

  12.   

    联通应该给你一个SOAP服务地址形如:http://localhost/test/SOAP/CulculatorServer.php?wsdl
    你在地址栏输入这个地址,如果能看到下如你的Culculator.wsdl文件内容,说明联通的SOAP接口正常,否则服务有问题;
    没问题你再试你的客户端程序!
      

  13.   


    兄弟,<soap:address location="http://localhost/test/SOAP/Server.php"/> 这样么?
    报错: string(25) "Could not connect to host" 
    还是说 <soap:address location="http://localhost/test/SOAP/Culculator.php"/>这样呢?
    报错: string(25) "Could not connect to host" 
      

  14.   

    我调用联通服务器成功
    但是 现在又出现一个问题3.1 成员登录(方法名:memberLogin)1. 接口说明
    本接口用于用户登录。2. 接口原形
    public OpResult memberLogin(LoginMes mes)3. 输入参数
    参数名称 类型          可为空 长度 说明
    mes LoginMes 否 登录参数类          属性          类型 可为空 长度 说明
    LoginMes login         Login 否 登录信息
             sessionID String Login         username String 否 手机长号
             password         String 否 登录密码
             userType         String 否 用户类型0:集团用户
             corpID         String 否 集团ID4. 返回值
    OpResult也就是说必须实例化 login 这个类 然后将结果 传到类 LoginMes 这个类 再实例化 传入方法memberLogin但是 现在除了 memberLogin方法是公开的 Login LoginMes都不可见
    这种情况下 是否只用调用移动给我们的wsdl文件 来生成必须的参数? 还是说 可以远程调用?
      

  15.   

    9楼的 你试试吧每个php文档的最后 ?> 这个去掉再调试下看 估计就可以了 因为莪刚刚也是因为这样的问题 纠结了半天挖、