PHP:带有复杂参数的soapCall
我正在尝试在供应商和我之间建立 SOAP 连接,以便在我们的数据库之间同步数据。 我成功地用一个简单的soapCall连接了他,抛出了php行($service是我正在访问的Soap函数的名称,$data是一个包含我的变量的关联数组):
$request = new SoapClient($client, array('soap_version' => SOAP_1_1));
$response = $request->$service($data);
如果我的XML方案,那么这些行就可以工作变量没有集合,如下例所示:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ServiceITryToReach xmlns="https://mysuplier:65100/">
<Login>login</Login>
<Password>pass</Password>
<Variables>
<Variable1>data</Variable1>
<Variable2>data</Variable2>
</Variables>
</ServiceITryToReach>
</soap:Body>
</soap:Envelope>
在上面的示例中,包含变量的关联数组将是:
array('Login'=>'login','Password'=>'pass','Variables'=>array('Variable1'=>'data','Variable2'=>'data'));
但是,如果我的 XML 方案包含相同类型的变量集合,我如何用关联数组表示它PHP 中的数组?
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ServiceITryToReach xmlns="https://mysuplier:65100/">
<Login>login</Login>
<Password>pass</Password>
<Variables>
<Variable>
<data>data</data>
</Variable>
<Variable>
<data>data</data>
</Variable>
<Variable>
<data>data</data>
</Variable>
</Variables>
</ServiceITryToReach>
</soap:Body>
</soap:Envelope>
总之,我正在寻找另一种简单的方法来向我的供应商请求多个变量。最好的办法是在我的soapCall 方法中使用直接的XML 输入,而不是关联数组。 一个想法? 谢谢, 尼科
I'm trying to set up a SOAP connexion between a supplier and I in order to synchronize data between our databases.
I've managed to connect him with a simple soapCall threw that php lines ($service is the name of the Soap function I'm reaching, and $data is an associative array that contains my variables) :
$request = new SoapClient($client, array('soap_version' => SOAP_1_1));
$response = $request->$service($data);
That lines work if my XML scheme of variables has no collections like in this example :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ServiceITryToReach xmlns="https://mysuplier:65100/">
<Login>login</Login>
<Password>pass</Password>
<Variables>
<Variable1>data</Variable1>
<Variable2>data</Variable2>
</Variables>
</ServiceITryToReach>
</soap:Body>
</soap:Envelope>
In the example above, my associative array that contains my variables will be :
array('Login'=>'login','Password'=>'pass','Variables'=>array('Variable1'=>'data','Variable2'=>'data'));
But, if my XML scheme contains collections of variables of same type, how can I represent it with an associative array in PHP ?
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ServiceITryToReach xmlns="https://mysuplier:65100/">
<Login>login</Login>
<Password>pass</Password>
<Variables>
<Variable>
<data>data</data>
</Variable>
<Variable>
<data>data</data>
</Variable>
<Variable>
<data>data</data>
</Variable>
</Variables>
</ServiceITryToReach>
</soap:Body>
</soap:Envelope>
In conclusion, I'm looking for another simple way to request my supplier with multiple variables. The best would be to have a direct XML input in my soapCall method instead of an associative array.
An idea ?
Thanks,
Nico
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论