标题: php webservice 传两个参数出错
jiewuzhe02
新手上路
Rank: 1



UID 11275
精华 0
积分 0
帖子 7
翻译 0
原创 0
阅读权限 10
注册 2009-10-6
状态 离线
发表于 2010-8-16 17:19  资料  短消息  加为好友 
php webservice 传两个参数出错

用PHP webservice 写的不好用, 两数相加时不能传递参数。。。。。

My name is HuGe
The ID IS:1001
Message = SoapFault exception: [SOAP-ENV:Server] Procedure 'ia' not present in E:\wamp\www\ws\ServerTest1.php:11 Stack trace: #0 E:\wamp\www\ws\ServerTest1.php(11): SoapClient->__soapCall('theSun', Array) #1 {main}

ServerTest1.php

<?php
$soap= new SoapClient('http://localhost/ws/Server1.wsdl');
//print_r($soap->getName());exit();
//var_dump($soap->getName());exit();
echo $soap->getName()."";  //输入姓名
echo "<br>";
echo $soap->setID(1001);
echo "<br>";
try {
$param=array('ia'=>1,'ib'=>2);
  echo $soap->__soapCall('theSun',array($param));
  
} catch (Exception $e) {
    printf("Message = %s",$e->__toString());
}
?>

Server1.php

<?php

/**
* @author kxgtop
*
*/
class SimpleClass
{

       /**
        * @return string
        */
       function getName()
       {
              return "My name is HuGe";
       }

       /**
        * @param string $id
        * @param string $name
        * @return string
        */
       function setID($id)
       {
              return "The ID IS:".$id;
       }

       /**
        * @param integer $ia
        * @param integer $ib
        * @return integer
        */
       function theSun($ia,$ib)
       {//echo $ia;
               //        $arr = explode(',',$ia);
               //        $all = floatval($arr[0])+floatval($arr[1]);
            return $ia+$ib;
       }

}

        $server   =   new   SoapServer( 'Server1.wsdl');
        $server-> setClass( 'SimpleClass');
        $server-> handle();

?>

Server1.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost/ws/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ws" targetNamespace="http://localhost/ws/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://localhost/ws/">
      <xsd:element name="getName">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="in" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="getNameResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="out" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="setId">
              <xsd:complexType>
                      <xsd:sequence>

                              <xsd:element name="in" type="xsd:string"></xsd:element>
                      </xsd:sequence>
              </xsd:complexType>
      </xsd:element>
      <xsd:element name="setIdResponse">
              <xsd:complexType>
                      <xsd:sequence>

                              <xsd:element name="out" type="xsd:string"></xsd:element>
                      </xsd:sequence>
              </xsd:complexType>
      </xsd:element>
      <xsd:element name="theSun">
              <xsd:complexType>
                      <xsd:sequence>

                              <xsd:element name="in" type="xsd:string"></xsd:element>
                      </xsd:sequence>
              </xsd:complexType>
      </xsd:element>
      <xsd:element name="theSunResponse">
              <xsd:complexType>
                      <xsd:sequence>

                              <xsd:element name="out" type="xsd:string"></xsd:element>
                      </xsd:sequence>
              </xsd:complexType>
      </xsd:element>
            <xsd:complexType name="int"></xsd:complexType>
        </xsd:schema>
  </wsdl:types>
  <wsdl:message name="getNameRequest">


  </wsdl:message>
  <wsdl:message name="getNameResponse">
    <wsdl:part name="name" type="xsd:string"/>
  </wsdl:message>
  <wsdl:message name="setIdRequest">
          <wsdl:part name="id" type="xsd:string"></wsdl:part>

  </wsdl:message>
  <wsdl:message name="setIdResponse">
          <wsdl:part name="newid" type="xsd:string"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="theSunRequest">
          <wsdl:part name="ia" type="xsd:integer"></wsdl:part>

          <wsdl:part name="ib" type="xsd:string"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="theSunResponse">
          <wsdl:part name="newsun" type="xsd:integer"></wsdl:part>
  </wsdl:message>
  <wsdl:portType name="ws">
    <wsdl:operation name="getName">
      <wsdl:input message="tns:getNameRequest"/>
      <wsdl:output message="tns:getNameResponse"/>
    </wsdl:operation>
    <wsdl:operation name="setId">
            <wsdl:input message="tns:setIdRequest"></wsdl:input>
            <wsdl:output message="tns:setIdResponse"></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="theSun">
            <wsdl:input message="tns:theSunRequest"></wsdl:input>
            <wsdl:output message="tns:theSunResponse"></wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="wsSOAP" type="tns:ws">
          <soap:binding style="document"
                  transport="http://schemas.xmlsoap.org/soap/http" />
          <wsdl:operation name="getName">
                  <soap:operation soapAction="http://localhost/ws/getName" />
                  <wsdl:input>
                          <soap:body use="literal" />
                  </wsdl:input>
                  <wsdl:output>
                          <soap:body use="literal" />
                  </wsdl:output>
          </wsdl:operation>
          <wsdl:operation name="setId">
                  <soap:operation soapAction="http://localhost/ws/setId" />
                  <wsdl:input>
                          <soap:body use="literal" />
                  </wsdl:input>
                  <wsdl:output>
                          <soap:body use="literal" />
                  </wsdl:output>
          </wsdl:operation>
          <wsdl:operation name="theSun">
                  <soap:operation soapAction="http://localhost/ws/theSun" />
                  <wsdl:input>
                          <soap:body use="literal" />
                  </wsdl:input>
                  <wsdl:output>
                          <soap:body use="literal" />
                  </wsdl:output>
          </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ws">
    <wsdl:port binding="tns:wsSOAP" name="wsSOAP">
      <soap:address location="http://localhost/ws/Server1.php"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


顶部
wozeal90
新手上路
Rank: 1



UID 23510
精华 0
积分 0
帖子 1
翻译 0
原创 0
阅读权限 10
注册 2011-5-15
状态 离线
发表于 2011-5-16 15:03  资料  短消息  加为好友 
Nike Mercurial Vapor Superfly II Wisdom to buy the best bottombrawl shoes appear


2011 Nike Mercurial Vapor Superfly II Elite FG Soccer Cleat Mens Soccer Shoes In Babridgement Oambit Color,Nike Mercurial Vapor Superfly III
ere's annihilation worse than award out you've been absolutely ripped off or you acclimatized for the amiss Puma cossack if you capital a brace of Umbros all forth. Cabundance Soccer Shoes ancients with ability superior is actual account to own.
It is your acumen to acquisition a acceptable and best footbrawl shoes for you. A good bottomball amateur is worth to own the best football shoe in the apple.

顶部
 


PHPEye开源社区


当前时区 GMT+8, 现在时间是 2012-2-10 11:47

    Powered by Discuz! 5.5.0  © 2001-2007 Comsenz Inc.
Processed in 0.014527 second(s), 8 queries , Gzip enabled

清除 Cookies - 联系我们 - PHPEye开源社区 - Archiver