我试图找到一种方法来建立一个PHP文件,该文件将使用基本用户名发送SOAP请求,并将身份验证传递给提供程序,然后获取响应并将其写入同一文件夹中的文件中。
它应该在每次调用时重写或更新文件。
具有详细信息的链接: https://www.ct4partners.com/ws/ctproductsinstock.asmx
答案 0 :(得分:0)
下面的简单示例:
<?php
/* Method GetCTProductGroups
<GetCTProductGroups xmlns="http://www.ct4partners.com/B2B"> <== 1. method
<username>string</username> <=== 2. param
<password>string</password> <=== 2. param
</GetCTProductGroups>
*/
$urlToWsdl = 'https://www.ct4partners.com/ws/ctproductsinstock.asmx?wsdl';
$client = new SoapClient($urlToWsdl);
$request = array(
'username' => 'login', //2. param
'password' => 'pass' //2. param
);
$client->GetCTProductGroups($request); //1. call method
$xml = $client->__getLastResponse(); // Get XML
//if response not empty (You must provide real login details / real data param)
if(isset($xml))
{
$dom = new DOMDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXML(
$xml,
LIBXML_HTML_NOIMPLIED |
LIBXML_HTML_NODEFDTD |
LIBXML_NOERROR |
LIBXML_NOWARNING
);
//Save XML as a file
$dom->save('response.xml');
}