在PHP中使用SoapClient通过https调用WCF时出现致命错误


Getting fatal-error on Calling WCF in PHP using SoapClient over https

我是服务新手,我目前正在使用SoapClient对象在PHP中调用。net WCF服务。代码如下:

    $arr2=array('paymentVendorCode'=>"test1",'transactionNumber'=>123456789,'dataSource'=>'Ghana_QA','customerNumber'=>45678912,'amount'=>10,'invoicePeriod'=>1,'currency'=>'GHC','paymentDescription'=>'CashPayment','methodofPayment'=>'CASH','productCollection'=>'PRCC4');
    $certFile = "certs/Entrust.pem";
    $options = array('soap_version' => SOAP_1_1 , 'local_cert' => $certFile , 'exceptions' => true ,'trace' => true ,'wdsl_local_copy' => true ,'ssl' => array('verify_peer' => false) ,'https' => array('curl_verify_ssl_peer'  => false, 'curl_verify_ssl_host' => false)
           );
try
{
echo "SOAP Client Object Made <br />";
//To Make soap client using WSDL files offline
$client = new SoapClient("RTPP_Web_Service_WSDL_20130306/multichoice.paymentservice.wsdl",$options);    
}
catch(SoapFault $E)
{
    echo "Error:--> ".$E->faultstring;
}
print_r($client->__getFunctions());
try
{
echo $pmt_customer=$client->__call("SubmitPayment", $arr2)."<br /><br />";
}
catch(SoapFault $fault)
{
echo "came here in catch";
trigger_error("SOAP Fault:(faultcode: {$fault->faultcode}'n"."faultstring: {$fault->faultstring})", E_USER_ERROR);  
 }

我已经通过我正在使用的所有WSDL文件,并获得了所有元素,消息,操作,参数等。其中一个WSDL文件中的soap地址如下:

<soap:address location="https://wispqa.multichoice.co.za/PaymentServicePerimeter/Intermediate.svc" />

是被调用的服务的实际地址,通常在url的末尾使用?WSDL来调用服务,但是即使在上面url的末尾添加了这个,服务页面的外观仍然是一样的。

服务文档中的一件事被写为"服务当前不使用消息契约"。

我正在向服务发送请求,从我通过调用"$client->__getFunction()"获得的列表中调用其方法之一。但是,它没有响应,而是给出致命的错误,可以从https://i.stack.imgur.com/GvS3d.png的屏幕截图中看到。

我已经为它工作了将近一个星期,但被困在这里。如果有人能把我弄出去的话。

我得到了我的答案,我缺少的是要调用的方法的soap操作。我通过彻底访问WSDL文件给出了soap操作,并为我调用的方法找到了soap操作:

  $submitpayment_action   = "http://MultiChoice.PaymentService/ServiceContracts/PaymentServiceContract/SubmitPayment";

我还通过使用xml格式改变了我的请求格式,其摘录如下(我通过使用SOAPUI工具获得了这个xml格式):

 $submitpay = "<?xml version='"1.0'" encoding='"UTF-8'"?>
<soapenv:Envelope xmlns:soapenv='"http://schemas.xmlsoap.org/soap/envelope/'"
xmlns:mes='"http://MultiChoice.PaymentService/MessageContracts'" 
                                        xmlns:ser='"http://MultiChoice.PaymentService/ServiceContracts'" 
                                        xmlns:dat='"http://MultiChoice.PaymentService/DataContracts'" 
                                        xmlns:mcom='"http://mcomp.scontracts'" xmlns:mcom1='"http://mcomp.dcontracts'">
                      <soapenv:Header/>
<soapenv:Body>
                        <mes:SubmitPaymentRequest>
                          <ser:PaymentRequest>
<dat:paymentVendorCode>".$vendorcode."</dat:paymentVendorCode> .......

,最后使用这个"__doRequest" SOAP方法来调用服务方法:

 $response = $client->__doRequest($submitpay,$location,$submitpayment_action,SOAP_1_1,$one_way = 0);
print_r($response);

这显示了我想要的响应。现在可以使用"simplexml_load_string($response);"从响应中提取所需的信息。, "registerXPathNamespace()"answers"xpath('//string');"方法。