2

我一直在做一些我认为我理解的事情:-)。我有一个用于提供 Web 服务的 SOAP 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>xxxxxxx</EndpointNm>
                    <Certificaat>xxxxxxxx</Certificaat>
                </Header>
                <Detail>
                    <EAN>9789084999912</EAN>
                    <OrderReference>1988763767</OrderReference>
                    <ClientId>K Koning</ClientId>
                    <ReadingMethods>CR</ReadingMethods>
                    <RetailerId>xxxxxx</RetailerId>
                </Detail>
            </CbOrderProduct >
        </arguments>
    </exec>
</soapenv:Body>

我把这个带有已知函数的文件放到一个数组中。然后我启动服务,但您没有听到任何响应。

$url = "https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL";
$client = new SoapClient($url);
$message = xml2array(file_get_contents('vraag.xml'));
echo $result = $client->exec($message);

谁能帮帮我?修复了非常感谢。

广告

4

2 回答 2

3

最后我解决了这个问题.. :)

下面的代码肯定会起作用。

$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>9789084999967</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);
于 2014-12-01T13:11:25.753 回答
2

当我打电话时new SoapClient("https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL");,我得到:致命错误:未捕获的 SoapFault 异常:[WSDL] SOAP-ERROR:解析 WSDL:无法从“ https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL ”加载:无法加载外部实体“ https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL ”我没有找到解决方案:SOAP-ERROR:解析 WSDL:无法从 <URL> 加载

也许您应该尝试:https ://github.com/mikaelcom/WsdlToPhp 。我认为你的代码应该像:

error_reporting(E_ALL);
ini_set('display_errors', 1);
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)
    {
                    $this->detail->EAN =$ean;
                    $this->detail->OrderReference = $orderreference;
                    $this->detail->ClientId = $clienid;
                    $this->detail->ReadingMethods = $readingmethods;
                    $this->detail->RetailerId = $retailerid;
    }   
}

class exec0Request {

    var $arguments;

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


$order = new CbOrderProduct();
$order->setheader('123','123abc');
$order->setdetail('9789084999912','1988763767','K Koning','CR','12345');
$request = new exec0Request($order);
$client = new SoapClient("https://tst.eboekhuis.nl/cbwebs/CBWSCallEngine?WSDL");
$result = $client->exec(new SoapParam($request, "exec0Request"));
于 2013-04-22T12:48:51.307 回答