【问题标题】:Writing a SOAP function in php用 php 编写一个 SOAP 函数
【发布时间】:2014-01-24 15:41:20
【问题描述】:

我有一个名为 get_file_list 的肥皂函数,我想为 PHP 编写它,但是我无法让它工作。它有三个参数,1)开始时间,2)结束时间,3)布尔值。这是示例代码在soap中的样子;

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:get_file_list soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://schemas.cisco.com/ast/soap/">
<in0 xsi:type="xsd:string">200511161000</in0>
<in1 xsi:type="xsd:string">200511161059</in1>
<in2 href="#id0"/>
</ns1:get_file_list>
<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:boolean"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">true</multiRef>
</soapenv:Body>
</soapenv:Envelope>

我是这样写PHP的;

$response = $soapClient->__get_file_list(array('$in0'=>'201401161000','$in1'=>'201401161059','$in2'=>'id0'));
print_r($response);

我知道我肯定在进行身份验证,并且 get_file_list 是一个真正的肥皂函数,因为我能够生成此输出;

Array
(
    [0] => ArrayOfFileName get_file_list(string $in0, string $in1, boolean $in2)
    [1] => void get_file(string $in0, string $in1, string $in2, string $in3, string $in4, boolean $in5)
)

当我执行页面时,它返回一个空白。任何帮助表示赞赏。

这里是wsdl

<wsdl:definitions targetNamespace="http://schemas.cisco.com/ast/soap/"><!--WSDL created by Apache Axis version: 1.4 With AXIS-2250
Built on Apr 22, 2006 (06:55:48 PDT)--><wsdl:types><schema targetNamespace="http://schemas.cisco.com/ast/soap/"><import namespace="http://schemas.xmlsoap.org/soap/encoding/"/><complexType name="ArrayOfFileName"><sequence><element maxOccurs="unbounded" minOccurs="0" name="FileName" nillable="true" type="xsd:string"/></sequence></complexType></schema></wsdl:types><wsdl:message name="get_file_listRequest"><wsdl:part name="in0" type="xsd:string"/><wsdl:part name="in1" type="xsd:string"/><wsdl:part name="in2" type="xsd:boolean"/></wsdl:message><wsdl:message name="get_fileResponse">

   </wsdl:message><wsdl:message name="get_fileRequest"><wsdl:part name="in0" type="xsd:string"/><wsdl:part name="in1" type="xsd:string"/><wsdl:part name="in2" type="xsd:string"/><wsdl:part name="in3" type="xsd:string"/><wsdl:part name="in4" type="xsd:string"/><wsdl:part name="in5" type="xsd:boolean"/></wsdl:message><wsdl:message name="get_file_listResponse"><wsdl:part name="get_file_listReturn" type="impl:ArrayOfFileName"/></wsdl:message><wsdl:portType name="CDRonDemand"><wsdl:operation name="get_file_list" parameterOrder="in0 in1 in2"><wsdl:input message="impl:get_file_listRequest" name="get_file_listRequest"/><wsdl:output message="impl:get_file_listResponse" name="get_file_listResponse"/></wsdl:operation><wsdl:operation name="get_file" parameterOrder="in0 in1 in2 in3 in4 in5"><wsdl:input message="impl:get_fileRequest" name="get_fileRequest"/><wsdl:output message="impl:get_fileResponse" name="get_fileResponse"/></wsdl:operation></wsdl:portType><wsdl:binding name="CDRonDemandSoapBinding" type="impl:CDRonDemand"><wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="get_file_list"><wsdlsoap:operation soapAction="http://schemas.cisco.com/ast/soap/action/#CDRonDemand#get_file_list"/><wsdl:input name="get_file_listRequest"><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.cisco.com/ast/soap/" use="encoded"/></wsdl:input><wsdl:output name="get_file_listResponse"><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.cisco.com/ast/soap/" use="encoded"/></wsdl:output></wsdl:operation><wsdl:operation name="get_file"><wsdlsoap:operation soapAction="http://schemas.cisco.com/ast/soap/action/#CDRonDemand#get_file"/><wsdl:input name="get_fileRequest"><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:CDRonDemand" use="encoded"/></wsdl:input><wsdl:output name="get_fileResponse"><wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://schemas.cisco.com/ast/soap/" use="encoded"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="CDRonDemandService"><wsdl:port binding="impl:CDRonDemandSoapBinding" name="CDRonDemand"><wsdlsoap:address location="https://<server_ip>:8443/CDRonDemandService/services/CDRonDemand"/></wsdl:port></wsdl:service></wsdl:definitions>

【问题讨论】:

  • 你为什么打电话给__get_file_list而不是get_file_list?为什么要调用参数'$in0' 而不是正确的'in0'
  • 嗨 Wrikken - 我正在研究我找到的一些示例。你会怎么写呢?
  • 我会从$soapClient-&gt;get_file_list(array('in0'=&gt;'201401161000','in1'=&gt;'201401161059','in2'=&gt;'id0')); 开始,看看它是否有效,如果无效,请使用__getLastRequest() 检查它实际发送的内容。
  • 嗨 Wrikken - 感谢您的回复。我将您的语法复制到了我的 php 中,但是当我尝试运行它时,它会爆炸。该行本身不会产生任何内容,并且在 __getLastRequest 或其下方的任何“echo 'Test'”行(用于测试)中都没有显示任何内容。如果我将该行注释掉,则所有行都将运行。我还禁用了 wsdl 的缓存以进一步隔离问题。有什么想法吗?
  • catch SoapFault,看看它说了什么(如果你在创建SoapClient 时将trace 设置为true,你还可以检查__getLastRequest()) .如果您有要分享的 wsdl,那也会有所帮助。

标签: php soap cucm cisco-axl


【解决方案1】:

格式其实是$soapClient->get_file_list('201401271000','201401271059','id0')。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 2014-03-08
    • 1970-01-01
    • 2022-08-17
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多