【问题标题】:Getting fatal-error on Calling WCF in PHP using SoapClient over https使用 SoapClient over https 在 PHP 中调用 WCF 时出现致命错误
【发布时间】:2013-03-19 10:20:43
【问题描述】:

我是服务新手,我目前正在使用 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()”的列表中调用其方法之一的服务发送请求。但它不是响应而是给出致命错误,可以从http://i.stack.imgur.com/GvS3d.png 的屏幕截图中看到。

我已经为此工作了将近一个星期,但被困在这里。请如果有人可以让我离开这里。提前致谢。

【问题讨论】:

    标签: php wcf wsdl webservice-client soap-client


    【解决方案1】:

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

      $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()" 和 "xpath('//string');"方法。

    【讨论】:

      猜你喜欢
      • 2011-09-28
      • 2011-03-16
      • 2015-11-06
      • 1970-01-01
      • 2012-10-06
      • 1970-01-01
      • 2019-02-16
      • 1970-01-01
      • 2016-06-14
      相关资源
      最近更新 更多