PHP肥皂客户端连接
问题描述:
您好我有休耕皂PHP肥皂客户端连接
SOAP 1.1
POST /ServicePeletalk.asmx HTTP/1.1
Host: 82.80.225.186
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://peletop.co.il/GetProducts"
<?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>
<GetProducts xmlns="http://peletop.co.il/">
<query>
<TerminalNum>string</TerminalNum>
<ProviderID>int</ProviderID>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<Language>Hebrew or Arabic or English</Language>
<LoadPictures>boolean</LoadPictures>
</query>
</GetProducts>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<GetProductsResponse xmlns="http://peletop.co.il/">
<GetProductsResult>
<Products>
<clsProduct>
<ProductIdenfity>string</ProductIdenfity>
<ProductName>string</ProductName>
<Description>string</Description>
<Picture>base64Binary</Picture>
<Price>double</Price>
<MaxPrice>double</MaxPrice>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<DetailsLink>string</DetailsLink>
</clsProduct>
<clsProduct>
<ProductIdenfity>string</ProductIdenfity>
<ProductName>string</ProductName>
<Description>string</Description>
<Picture>base64Binary</Picture>
<Price>double</Price>
<MaxPrice>double</MaxPrice>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<DetailsLink>string</DetailsLink>
</clsProduct>
</Products>
</GetProductsResult>
</GetProductsResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是一个示例SOAP 1.2请求和响应。显示的占位符需要用实际值替换。
POST /ServicePeletalk.asmx HTTP/1.1
Host: 82.80.225.186
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetProducts xmlns="http://peletop.co.il/">
<query>
<TerminalNum>string</TerminalNum>
<ProviderID>int</ProviderID>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<Language>Hebrew or Arabic or English</Language>
<LoadPictures>boolean</LoadPictures>
</query>
</GetProducts>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetProductsResponse xmlns="http://peletop.co.il/">
<GetProductsResult>
<Products>
<clsProduct>
<ProductIdenfity>string</ProductIdenfity>
<ProductName>string</ProductName>
<Description>string</Description>
<Picture>base64Binary</Picture>
<Price>double</Price>
<MaxPrice>double</MaxPrice>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<DetailsLink>string</DetailsLink>
</clsProduct>
<clsProduct>
<ProductIdenfity>string</ProductIdenfity>
<ProductName>string</ProductName>
<Description>string</Description>
<Picture>base64Binary</Picture>
<Price>double</Price>
<MaxPrice>double</MaxPrice>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<DetailsLink>string</DetailsLink>
</clsProduct>
</Products>
</GetProductsResult>
</GetProductsResponse>
</soap12:Body>
</soap12:Envelope>
我该如何在PHP中编写它?
我试图
<?
// Maximum error reporting
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
$wsdl = 'http://82.80.225.186:8000/ServicePeletalk.asmx?WSDL';
$trace = true;
$exceptions = true;
$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions));
$xml_array['TerminalNum'] = 5089 ;
$xml_array['UserType'] = 'SiteUser';
$xml_array['Language'] = 'English';
$xml_array['ConnectionOrDeviceID'] = '879d62-EA47-4520-8A29-EB5981A62DD8';
try
{
$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions));
$response = $client->GetSellerProviders($xml_array);
}
catch (Exception $e)
{
echo "Error!";
echo $e -> getMessage();
echo 'Last response: '. $client->__getLastResponse();
}
?>
它不工作
请帮助
答
对于第一次看,似乎,根据您的XML文件,你必须调用$client->GetProducts
,而不是$client->GetSellerProviders
,因为在xml文件中有一个名为GetProducts
的元素。
如果这是一个错字,你真的叫$client->GetProducts
然后检查$xml_array
结构是这样的
$xml_array['query']['TerminalNum'] = 5089 ;
$xml_array['query']['UserType'] = 'SiteUser';
$xml_array['query']['Language'] = 'English';
$xml_array['query']['ConnectionOrDeviceID'] = '879d62-EA47-4520-8A29-EB5981A62DD8';
包括query
元素如XML请求样本。
从评论UPDATE
我看到,请求XML具有以下元素
<TerminalNum>string</TerminalNum>
<ProviderID>int</ProviderID>
<CardType>All or Virtual or Manual or BillPayment</CardType>
<Language>Hebrew or Arabic or English</Language>
<LoadPictures>boolean</LoadPictures>
所以$xml_array
变量应该有这些元素就像名字的数组:
$xml_array['query']['TerminalNum'] = 5089 ;
$xml_array['query']['ProviderID'] = 'SiteUser';
$xml_array['query']['CardType'] = 'som card type';
$xml_array['query']['Language'] = 'English';
$xml_array['query']['LoadPictures'] = 'true';
嗨Whiteulver,我试过了,但它不起作用 – YossefB
我收到来自服务器的错误发送空值 – YossefB
我对我的答案做了一些编辑。请试试这个数组结构。也可以尝试使用和不使用'query'元素来查看它是否可以工作 – Whiteulver