我试图弄清楚如何使用SOAP接口。
在使用soapUI进行探索之后,我设法将代码放在一起。
使用soapUI请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v22="https://shop.textalk.se/webservice/v22">
<soapenv:Header/>
<soapenv:Body>
<v22:GetOrders>
<Login>
<Shop>23946</Shop>
<Username>user@mysite.com</Username>
<Password>HIDDEN</Password>
</Login>
<!--Zero or more repetitions:-->
<Orders>44753668</Orders>
<Status>All</Status>
</v22:GetOrders>
</soapenv:Body>
</soapenv:Envelope>
不可用的PHP请求:
<?php
$wsdl = "https://shop.textalk.se/webservice/v22/?WSDL";
$client = new SoapClient($wsdl, array(
'Shop'=>'23946',
'Username'=>'user@mysite.com',
'Password'=>'HIDDEN',
'trace'=>1,
'exceptions'=>0));
$request = array(
'GetOrdersResponse' => array(
'Orders' => '44753668',
'Status' => 'All'
),
);
$response = $client->GetOrders($request);
var_dump($response);
echo $response;
?>
文档在这里:https://shop.textalk.se/webservice/v22/wsdldoc.php
当我运行php代码时,绝对没有任何反应
答案 0 :(得分:0)
我不是PHP专家,但您尝试过以下代码吗?
<?php
$wsdl = "https://shop.textalk.se/webservice/v22/?WSDL";
$client = new SoapClient($wsdl);
$request = array(
'Shop'=>'23946',
'Username'=>'user@mysite.com',
'Password'=>'HIDDEN',
'Orders' => '44753668',
'Status' => 'All'));
$response = $client->GetOrders($request);
var_dump($response);
echo $response;
?>
查看此博文,了解良好的起点http://www.vankouteren.eu/blog/2009/03/simple-php-soap-example/
注意:代码未经测试!
答案 1 :(得分:0)
我发现了什么问题。我必须将登录值作为数组传递,而不是作为单独的值传递。这解决了它。我现在正在获得正确的数据。
<?php
$wsdl = "https://shop.textalk.se/webservice/v22/?WSDL";
$client = new SoapClient($wsdl);
$request = array(
'Login' => array(
'Shop'=>"23946",
'Username'=>"mail@mysite.com",
'Password'=>"HIDDEN"),
'Orders' => "44753668",
'Status' => "All");
$response = $client->GetOrders($request);
var_dump($response);
echo $response;
?>