我在下面给出了Wsdl文件,请求实例和预期的响应实例,我需要的是如何执行它以在php中使用SOAP获得预期的响应。
我需要知道如何按预期向soap环境和响应发送请求。所以请为我提供解决方案。
截至文档
如果需要通知SMS送达回执,则notifySmsDeliveryReceipt操作必须由应用程序端的Web Service实现。当应用程序发送的SMS已经发送到收件人的终端或者如果无法交付时,Parlay X 3服务器将调用它来通知应用程序。当且仅当已发送SMS的状态为DeliveredToTerminal或DeliveryImpossible并且应用程序在使用以下互斥机制之一发送SMS消息时指定了对通知的兴趣时,将发生通知: 通过指定可选的receiptRequest部分。返回的相关因子对应于应用程序在原始sendSMS请求的receiptRequest中指定的标识符。 通过调用startDeliveryReceiptNotification操作请求接收送达回执通知。返回的相关因子对应于应用程序在原始startDeliveryReceiptNotification请求的引用中指定的标识符
wsdl文件:
<?xml version="1.0" encoding="UTF-8"?>
<!-- March 7, 2007 -->
<wsdl:definitions
name="parlayx_sms_notification_service"
targetNamespace="http://www.csapi.org/wsdl/parlayx/sms/notification/v3_1/service"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.csapi.org/wsdl/parlayx/sms/notification/v3_1/service"
xmlns:interface="http://www.csapi.org/wsdl/parlayx/sms/notification/v3_1/interface">
<wsdl:import namespace="http://www.csapi.org/wsdl/parlayx/sms/notification/v3_1/interface" location="parlayx_sms_notification_interface_3_1.wsdl"/>
<wsdl:binding name="SmsNotificationBinding" type="interface:SmsNotification">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="notifySmsReception">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:header message="interface:NotifySOAPHeader" part="NotifySOAPHeader" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="notifySmsDeliveryReceipt">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:header message="interface:NotifySOAPHeader" part="NotifySOAPHeader" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SmsNotificationService">
<wsdl:port name="SmsNotification" binding="tns:SmsNotificationBinding">
<soap:address location="http://localhost:9080/SmsNotificationService/services/SmsNotification"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
SOAP请求实例:
<soapenv:Envelope xmlns:soapenv=‘http://schemas.xmlsoap.org/soap/envelope/’ xmlns:v3=‘http://www.csapi.org/schema/parlayx/common/v3_1’ xmlns:loc=‘http://www.csapi.org/schema/parlayx/sms/notification/v3_1/local’>
<soapenv:Header>
<v3:NotifySOAPHeader>
<spId>600002</spId>
</v3:NotifySOAPHeader>
</soapenv:Header>
<soapenv:Body>
<loc:notifySmsDeliveryReceipt>
<loc:correlator>123</loc:correlator>
<loc:deliveryStatus>
<address>tel:+86123</address>
<deliveryStatus>DeliveredToTerminal</deliveryStatus>
</loc:deliveryStatus>
</loc:notifySmsDeliveryReceipt>
</soapenv:Body>
</soapenv:Envelope>
响应实例:
<soapenv:Envelope xmlns:soapenv=‘http://schemas.xmlsoap.org/soap/envelope/’ xmlns:loc=‘http://www.csapi.org/schema/parlayx/sms/notification/v3_1/local’>
<soapenv:Header/>
<soapenv:Body>
<loc:notifySmsDeliveryReceiptResponse/>
</soapenv:Body>
</soapenv:Envelope>
答案 0 :(得分:0)
首先阅读本文 PHP: SoapClient class reference
所有php的Faps SoapClient是一个类,它提供了一个允许你处理web服务所具有的功能的对象,我将告诉你我是如何做到这一点,当我不得不像2个月前一样工作。
让我们创建实例
$url = 'http://this.is.the.server:somePort/the_service?wsdl';
$soapObject = new SoapClient($url, array('with some options, check the docs'));
让我们调用方法 使用服务函数中具有的确切名称传递参数非常重要。
$response = $soapObject->theFunctionName(array('parameter1' => 'value1',
'parameter2' => 'value2'));
获取返回值的简单方法 这只是我的观点,但我认为使用参考数组而不是映射到对象更容易(可能因为我习惯了它)。
function transformSoapResponseToArray($response){
$refArrayOfResponse= json_encode($response);
return json_decode($refArrayOfResponse, true);
}
希望我的回答能帮到你。