<wsdl:definitions targetNamespace="http://ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com" xmlns:intf="http://ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com" xmlns:tns1="http://req.ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com" xmlns:tns2="http://rsp.ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
 <wsdl:types>
  <schema elementFormDefault="qualified" targetNamespace="http://ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://req.ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com"/>
   <import namespace="http://rsp.ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com"/>
   <element name="queryPoint">
    <complexType>
     <sequence>
      <element name="req" type="tns1:PointQueryReq"/>
     </sequence>
    </complexType>
   </element>
   <element name="queryPointResponse">
    <complexType>
     <sequence>
      <element name="queryPointReturn" type="tns2:PointQueryRsp"/>
     </sequence>
    </complexType>
   </element>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://req.ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://rsp.ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com"/>
   <complexType name="PointQueryReq">
    <sequence>
     <element name="SPID" nillable="true" type="xsd:string"/>
     <element name="transactionID" nillable="true" type="xsd:string"/>
     <element name="userID" nillable="true" type="xsd:string"/>
     <element name="userToken" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
  <schema elementFormDefault="qualified" targetNamespace="http://rsp.ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com" xmlns="http://www.w3.org/2001/XMLSchema">
   <import namespace="http://req.ui.server.pointquery.vas.soap.interfaces.lcsmp.linkage.com"/>
   <complexType name="PointQueryRsp">
    <sequence>
     <element name="description" nillable="true" type="xsd:string"/>
     <element name="point" nillable="true" type="xsd:string"/>
     <element name="pointRate" type="xsd:int"/>
     <element name="result" nillable="true" type="xsd:string"/>
     <element name="transactionID" nillable="true" type="xsd:string"/>
     <element name="userID" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>
  </schema>
 </wsdl:types>   <wsdl:message name="queryPointResponse">      <wsdl:part element="impl:queryPointResponse" name="parameters">      </wsdl:part>   </wsdl:message>   <wsdl:message name="queryPointRequest">      <wsdl:part element="impl:queryPoint" name="parameters">      </wsdl:part>   </wsdl:message>   <wsdl:portType name="PointQueryService">      <wsdl:operation name="queryPoint">         <wsdl:input message="impl:queryPointRequest" name="queryPointRequest">       </wsdl:input>         <wsdl:output message="impl:queryPointResponse" name="queryPointResponse">       </wsdl:output>      </wsdl:operation>   </wsdl:portType>   <wsdl:binding name="PointQueryServiceSoapBinding" type="impl:PointQueryService">      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>      <wsdl:operation name="queryPoint">         <wsdlsoap:operation soapAction=""/>         <wsdl:input name="queryPointRequest">            <wsdlsoap:body use="literal"/>         </wsdl:input>         <wsdl:output name="queryPointResponse">            <wsdlsoap:body use="literal"/>         </wsdl:output>      </wsdl:operation>   </wsdl:binding>   <wsdl:service name="PointQueryServiceService">      <wsdl:port binding="impl:PointQueryServiceSoapBinding" name="PointQueryService">         <wsdlsoap:address location="http://tempuri.org/SoapPro/services/PointQueryService"/>      </wsdl:port>   </wsdl:service></wsdl:definitions>
以上是我要去访问的WebService的WSDL文档。我要用PHP语言去访问queryPoint这个功能接口。
于是我编写的代码核心部分如下:
@require_once(_SysDir_ . '/inc/lib/soap/nusoap.php');

$pclient = new soapclient('http://192.168.11.4:12000/payApi/do/purchase/PointQueryService.wsdl');
$pclient->soap_defencoding = 'utf-8';
$pclient->xml_encoding = 'utf-8';

$now_time = time();
$randStr = getRandomString(18);

class PointQueryReq
{
public $SPID;
public $transactionID;
public $userID;
public $userToken; 
}

class requestZ
{
public $req;
}

$InputZ=new PointQueryReq();
$InputZ->SPID=$jsdx_api_spid;
$InputZ->userID=$_POST['VAccount'];
$InputZ->transactionID=''.$jsdx_api_spid.date('YmdHis', $now_time).$randStr;
$InputZ->userToken=$_POST['userToken'];

$requstZ=new requestZ();
$requstZ->req=$InputZ;

    $param = new SoapParam($requstZ, 'tns1:PointQueryReq');

$try_times = 0 ;
$queryResutl='';
while (true)
{
$queryResutl = @$pclient->__soapCall('queryPoint',array('queryPointRequest'=>$param));

if ($queryResutl != "")
{
break;
}

if ($try_times > 3)
{
break;
}
$try_times++;
}
结果在网页上提示如下错误:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in D:\WWW\payApi\do\purchase\jsdx.inc.php:88 Stack trace。这是我第一次去学着看懂WSDL,并且尝试用PHP去访问,数据格式是我参考了很多例子写的,
不知道是否正确,麻烦高人指点。可以留QQ交流,大家交个朋友。

解决方案 »

  1.   

    可用的方法
    print_r($pclient->__getFunctions()); 
    可用的数据结构
    print_r($pclient->__getTypes()); 对于你的 WSDL 是
    Array
    (
        [0] => queryPointResponse queryPoint(queryPoint $parameters)
    )
    Array
    (
        [0] => struct queryPoint {
     PointQueryReq req;
    }
        [1] => struct queryPointResponse {
     PointQueryRsp queryPointReturn;
    }
        [2] => struct PointQueryReq {
     string SPID;
     string transactionID;
     string userID;
     string userToken;
    }
        [3] => struct PointQueryRsp {
     string description;
     string point;
     int pointRate;
     string result;
     string transactionID;
     string userID;
    }
    )