简体   繁体   English

使用SOAP从WSDL检索值-PHP

[英]Retrieve value from WSDL using SOAP - PHP

I have a very poor, in structure, WSDL file and I can't understand how I can retrieve information from it. 我的WSDL文件结构非常糟糕,无法理解如何从中检索信息。

VM is not accessible from an outside network so I can't share the whole WSDL file 无法从外部网络访问VM,因此无法共享整个WSDL文件

I would like to use getList function that takes an argument and returns a string, with multiple values. 我想使用接受参数并返回具有多个值的字符串的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>

My question is, because value is included inside return tag, I don't know how I can store it in a PHP variable using SOAP. 我的问题是,因为值包含在return标记内,所以我不知道如何使用SOAP将其存储在PHP变量中。

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

Even if I am using static numbers as passing arguments it always returns the values that contained to the user with id = 1. 即使我使用静态数字作为传递参数,它也始终会返回ID = 1的包含给用户的值。

From a blog post (which is removed now :( ) >> 从博客帖子( 现在删除: ()>>

<?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);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM