<?php
$client = new SoapClient("http://x.x.x.x/services/DesignDepartment?wsdl");
$params = array('ID'=>'1', 'M'=>'aaa'); 
$s=$cliente->__call('findInfo',$params);
print_r($s);
?>
错误:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in D:\html\soap.php:4 Stack trace: #0 D:\html\soap.php(4): SoapClient->__call('findInfo', Array) #1 {main} thrown in D:\html\soap.php on line 4如果加入以下语句:
echo "<p>"."Fun:"."<br>";
print_r($client->__getFunctions());
echo "</p><p>"."Types:"."<br>";
print_r($client->__getTypes());
echo "</p>";
可以得到返回结果:Fun:
Array ( [0] => findInfoResponse findInfo(findInfo $parameters) [1] => findInfoResponse findInfo(findInfo $parameters) )Types:
Array ( [0] => struct findInfo { string ID; string M; } [1] => struct findInfoResponse { string CODE; string ADDR_INFO; string ORG_INFO; } ) 请问我怎么做才能得到findInfo函数的返回值?
wsdl文件:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/DesignDepartment/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="DesignDepartment" targetNamespace="http://www.example.org/DesignDepartment/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://www.example.org/DesignDepartment/">
      <xsd:element name="findInfo">
        <xsd:complexType>
          <xsd:sequence>
           <xsd:element name="ID" type="xsd:string" />
           <xsd:element name="M" type="xsd:string" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="findInfoResponse">
        <xsd:complexType>
          <xsd:sequence>
           <xsd:element name="CODE" type="xsd:string" />
           <xsd:element name="ADDR_INFO" type="xsd:string" />
           <xsd:element name="ORG_INFO" type="xsd:string" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="findInfoRequest">
    <wsdl:part element="tns:findInfo" name="parameters"/>
  </wsdl:message>
  <wsdl:message name="findInfoResponse">
    <wsdl:part element="tns:findInfoResponse" name="parameters"/>
  </wsdl:message>
  <wsdl:portType name="DesignDepartment">
    <wsdl:operation name="findInfo">
      <wsdl:input message="tns:findInfoRequest"/>
      <wsdl:output message="tns:findInfoResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="DesignDepartmentSOAP" type="tns:DesignDepartment">   <soap:binding style="document"
   transport="http://schemas.xmlsoap.org/soap/http" />
   <wsdl:operation name="findInfo">   <soap:operation
   soapAction="http://www.example.org/DesignDepartment/findInfo" />
   <wsdl:input>   <soap:body use="literal" />
   </wsdl:input>
   <wsdl:output>   <soap:body use="literal" />
   </wsdl:output>
   </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="DesignDepartment">
    <wsdl:port binding="tns:DesignDepartmentSOAP" name="DesignDepartmentSOAP">
      <soap:address location="http://www.example.org/"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

解决方案 »

  1.   

    $cliente => $client
      

  2.   

    抱歉,刚才是我打错了,就是$client,不是$cliente.
      

  3.   

    这种错误产生的原因很多种,
    1 比如说编码,我们常见的bob
    2 调用函数的时候发生内部服务器错误, 500
    3 缓存原因
      

  4.   

    soap就这个鸟样, 没啥好办法, 只能你自己调试。
    服务器端是不是你写的,如果是你写的, 可以先在哪边入手来处理。
    没有问题以后,再尝试调用。
      

  5.   

    你给出真实可用的 url,我可以告诉你错误在哪里
      

  6.   

    $s=$cliente->__call('findInfo',$params);
    try, 改成:
    $s=$cliente->findInfo($params);
    print_r($s);
    exit();
      

  7.   

    这种情况一般是服务器的程序有问题
    你这情况可以看看`findInfo`方法是否报错或是警告之类的,都会导致返回给client的文档格式错乱
      

  8.   

    感谢楼上两位朋友的解答,我按照楼上的方法改了一下还是不成。我换了nusoap也不行,服务器那端好像是用java+xml做的,服务器开发的人员在他们那边测试了,都正常。我试了好几种方法了,都不行,不知道没有朋友遇到过我这种情况呀?
      

  9.   

    更改了程序,能正常连接服务器了,但输出结果不正确:
    <?php  
    ini_set("soap.wsdl_cache_enabled", "0"); 
    $wsdl="http://10.0.56.8/services/DesignDepartment?wsdl";  
    try {
    $options = array(
    'soap_version'=>SOAP_1_2,
    'exceptions'=>true,
    'trace'=>1,
    'cache_wsdl'=>WSDL_CACHE_NONE,
    'location' => "http://10.0.56.8/services/DesignDepartment"
    ); $client = new SoapClient($wsdl, $options);
     $client->soap_defencoding = 'utf-8'; 
     $client->decode_utf8 = false; 
     $client->xml_encoding = 'utf-8';   $parameters = array('ID'=>'1', 'M'=>'bj');
     $p=$client->findInfo($parameters);
     print_r ($p);
     var_dump($client->__getLastResponse());}catch(SoapFault $soapFault){
        echo $soapFault;
    }
    ?>输出如下:
    stdClass Object ( )
    string '<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><findInfoResponse xmlns="http://www.example.org/DesignDepartment/"><findInfoResponse xmlns="" ADDR_INFO="北京 北京" ORG_INFO="北京" CODE="0000" /></findInfoResponse></soapenv:Body></soapenv:Envelope>'stdClass Object ( )这句是print_r ($p)输出的,好像总是返回一个空的类型.
    可是看var_dump($client->__getLastResponse());最后一次返回的结果是正确的现在不知道应该怎么处理了,希望有朋友能帮我解决一下。