PHP - SOAP - WSDL:找不到反序列化错误 [英] PHP - SOAP - WSDL: No Deserializer found to deserialize Error

查看:29
本文介绍了PHP - SOAP - WSDL:找不到反序列化错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我必须使用的 xml 文件格式:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-实例" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soapenv:Body><exec xmlns="CBWSCallEngine" soapenv:encodingStyle="http://xml.apache.org/xml-soap/literalxml"><参数><CbOrderProduct><标题><端点Nm>123456789</端点Nm><证书>abcdef</证书></标题><详情><EAN>9789460941726</EAN><OrderReference>201406100527</OrderReference><ClientId></ClientId><阅读方法>D</阅读方法><RetailerId></RetailerId><许可></许可><RentalUnits></RentalUnits><RentalNumberOfUnits></RentalNumberOfUnits></详细信息></CbOrderProduct></参数></exec></soapenv:Body></soapenv:信封>

这是 WSDL URL:https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL

每次尝试时,我都会收到以下错误消息:

致命错误:未捕获的 SoapFault 异常:[SOAP-ENV:Client] 未找到使用编码样式null"反序列化:CbOrderProduct"的反序列化器.[java.lang.IllegalArgumentException]

我尝试了如下简单的 SoapVar:

$xml .='';$xml .='<标题>';$xml .= '<EndpointNm>123456</EndpointNm>';$xml .='abcdef';$xml .= '</Header>';$xml .='<详细信息>';$xml .= '<EAN>9789460941726</EAN>';$xml .= '<OrderReference>201406100527</OrderReference>';$xml .= '<ClientId></ClientId>';$xml .= '<ReadingMethods>D</ReadingMethods>';$xml .= '<RetailerId></RetailerId>';$xml .='<许可证>';$xml .= '<RentalUnits></RentalUnits>';$xml .= '<RentalNumberOfUnits></RentalNumberOfUnits>';$xml .= '</Detail>';$xml .= '</CbOrderProduct>';$client = 新 SoapClient(空值,大批('位置' =>'https://tst.eboekhuis.nl:443/cbwebs/CBWSCallEngine','uri' =>'https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL','跟踪' =>1、'使用' =>SOAP_LITERAL));$params = new SoapVar($xml, XSD_ANYXML);$result = $client->exec($params);

我也试过像下面这样我在stackoverflow上找到的:

class CbOrderProduct{var $Header;var $Detail;函数 __construct(){$this->Header = new stdClass();$this->Detail = new stdClass();}函数 setheader($endpoint,$Certificaat){$this->Header->EndpointNm = $endpoint;$this->Header->Certificaat = $Certificaat;}function setdetail($ean,$orderreference,$clienid,$readingmethods,$retailerid,$License,$RentalUnit,$RentalNumberOfUnits){$this->Detail->EAN =$ean;$this->Detail->OrderReference = $orderreference;$this->Detail->ClientId = $clienid;$this->Detail->ReadingMethods = $readingmethods;$this->Detail->RetailerId = $retailerid;$this->Detail->License = $License;$this->Detail->RentalUnit = $RentalUnit;$this->Detail->RentalNumberOfUnits = $RentalNumberOfUnits;}}类 exec0Request {var $arguments;函数 __construct($arguments){$this->arguments = $arguments;}}$order = new CbOrderProduct();$order->setheader('123456','abcdef');$order->setdetail('9789460941726','201406100527','','CR','','','','');$request = new exec0Request($order);$client = new SoapClient("https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL");$result = $client->exec(new SoapParam($request, "exec0Request"));

它们都不起作用.我尝试了不同类型的 xml 文件.

谁能告诉我问题是什么?

解决方案

这个问题我终于解决了.. :)下面的代码肯定会起作用.$xml = '<soapenv:信封xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soapenv:Body><exec xmlns="CBWSCallEngine"soapenv:encodingStyle="http://xml.apache.org/xml-soap/literalxml"><参数><CbOrderProduct xmlns="http://www.cbonline.nl/xsd"><标题><EndpointNm>*********</EndpointNm><证书>***********</证书></标题><详情><EAN>9789460941726</EAN><OrderReference>1988763767</OrderReference><阅读方法>D</阅读方法><RetailerId>12345</RetailerId></详细信息></CbOrderProduct></参数></exec></soapenv:Body></soapenv:Envelope>';$sUrl = 'https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL';//设置参数$ch = curl_init();curl_setopt($ch, CURLOPT_URL,$sUrl);curl_setopt($ch, CURLOPT_VERBOSE, 1);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);$sOutput = curl_exec($ch);curl_close($ch);echo "

";print_r($sOutput);

This is the xml file format I have to use:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soapenv:Body>
<exec xmlns="CBWSCallEngine" soapenv:encodingStyle="http://xml.apache.org/xml-soap/literalxml">
<arguments>
<CbOrderProduct>
<Header>
<EndpointNm>123456789</EndpointNm>
<Certificaat>abcdef</Certificaat>
</Header>
<Detail>
<EAN>9789460941726</EAN>
<OrderReference>201406100527</OrderReference>
<ClientId></ClientId>
<ReadingMethods>D</ReadingMethods>
<RetailerId></RetailerId>
<License></License>
<RentalUnits></RentalUnits>
<RentalNumberOfUnits></RentalNumberOfUnits>
</Detail>
</CbOrderProduct>
</arguments>
</exec>
</soapenv:Body>
</soapenv:Envelope>

this is WSDL URL: https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL

everytime I try, I get below error message:

Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] No Deserializer found to deserialize a ':CbOrderProduct' using encoding style 'null'. [java.lang.IllegalArgumentException]

I tried simple SoapVar like below:

$xml .= '<CbOrderProduct>';
$xml .= '<Header>';
$xml .= '<EndpointNm>123456</EndpointNm>';
$xml .= '<Certificaat>abcdef</Certificaat>';
$xml .= '</Header>';
$xml .= '<Detail>';
$xml .= '<EAN>9789460941726</EAN>';
$xml .= '<OrderReference>201406100527</OrderReference>';
$xml .= '<ClientId></ClientId>';
$xml .= '<ReadingMethods>D</ReadingMethods>';
$xml .= '<RetailerId></RetailerId>';
$xml .= '<License></License>';
$xml .= '<RentalUnits></RentalUnits>';
$xml .= '<RentalNumberOfUnits></RentalNumberOfUnits>';
$xml .= '</Detail>';
$xml .= '</CbOrderProduct>';

$client = new SoapClient(
    null,
    array(
        'location' => 'https://tst.eboekhuis.nl:443/cbwebs/CBWSCallEngine',
        'uri' => 'https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL',
        'trace' => 1,
        'use' => SOAP_LITERAL
    )
);
$params = new SoapVar($xml, XSD_ANYXML);
$result = $client->exec($params);

Also I tried like below which I found on stackoverflow:

class CbOrderProduct
{
    var $Header;
    var $Detail;

    function __construct()
    {
                $this->Header = new stdClass();
                $this->Detail = new stdClass();
    }
    function setheader($endpoint,$Certificaat)
    {
        $this->Header->EndpointNm = $endpoint;
        $this->Header->Certificaat = $Certificaat;
    }   

    function setdetail($ean,$orderreference,$clienid,$readingmethods,$retailerid,$License,$RentalUnit,$RentalNumberOfUnits)
    {
        $this->Detail->EAN =$ean;
        $this->Detail->OrderReference = $orderreference;
        $this->Detail->ClientId = $clienid;
        $this->Detail->ReadingMethods = $readingmethods;
        $this->Detail->RetailerId = $retailerid;
        $this->Detail->License = $License;
        $this->Detail->RentalUnit = $RentalUnit;
        $this->Detail->RentalNumberOfUnits = $RentalNumberOfUnits;

    }   
}

class exec0Request {

    var $arguments;

    function __construct($arguments) 
    {
        $this->arguments = $arguments;
    }
}


$order = new CbOrderProduct();
$order->setheader('123456','abcdef');
$order->setdetail('9789460941726','201406100527','','CR','','','','');
$request = new exec0Request($order);
$client = new SoapClient("https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL");
$result = $client->exec(new SoapParam($request, "exec0Request"));

none of them work. I tried different type of xml files.

could anyone let me know what the problem is?

解决方案

Finally I have solved this issue.. :)
Below code will definitely work.

$xml = '<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soapenv:Body>
<exec xmlns="CBWSCallEngine"
soapenv:encodingStyle="http://xml.apache.org/xml-soap/literalxml">
<arguments>
<CbOrderProduct xmlns="http://www.cbonline.nl/xsd">
<Header>
<EndpointNm>*********</EndpointNm>
<Certificaat>***********</Certificaat>
</Header>
<Detail>
<EAN>9789460941726</EAN>
<OrderReference>1988763767</OrderReference>
<ReadingMethods>D</ReadingMethods>
<RetailerId>12345</RetailerId>
</Detail>
</CbOrderProduct>
</arguments>
</exec>
</soapenv:Body>
</soapenv:Envelope>';

$sUrl = 'https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL';

// set parameters

 $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$sUrl);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $sOutput = curl_exec($ch);
    curl_close($ch);
    echo "<pre>";
    print_r($sOutput);

这篇关于PHP - SOAP - WSDL:找不到反序列化错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆