使用SOAP - PHP从WSDL检索值


Retrieve value from WSDL using SOAP - PHP

我有一个结构非常差的WSDL文件,我不明白如何从中检索信息。

VM不能从外部网络访问,所以我不能共享整个WSDL文件

我想使用getList函数,它接受一个参数并返回一个字符串,具有多个值。

SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header/>
    <S:Body>
        <ns2:getList xmlns:ns2="http://Wishlist.eBookCafe/">
            <arg0>2</arg0>
        </ns2:getList>
    </S:Body>
</S:Envelope>
SOAP Response
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:getListResponse xmlns:ns2="http://Wishlist.eBookCafe/">
            <return>[1]</return>
        </ns2:getListResponse>
    </S:Body>
</S:Envelope>

我的问题是,因为值包含在return标记内,我不知道如何使用SOAP将其存储在PHP变量中。

$list = $service->getList(array('arg0'=>$id));
print_r($list);

即使我使用静态数字作为传递参数,它也总是返回包含id = 1的用户的值。

摘自一篇博客文章(现已删除:()>

<?php
$url = 'your_url_orFilePath';
$client = new SoapClient($url);
$xmlr = new SimpleXMLElement("<main_key></main_key>");
$xmlr->addChild('childName1', $childName1);
$xmlr->addChild('childName2', $childName2);
------
----likewise---
$params = new stdClass();
$params->xml = $xmlr->asXML();
$result = $client->main_key_function($params);
?>