我必须使用PHP将最近订单的XML发送到Web服务,我正在努力弄清楚如何连接到Web服务,授权和发送所需的数据。
我有网络服务网址:
https://xxxxx.co.uk/xxxxx/OrderRelay.svc?wsdl
客户端代码,用户名和密码。
我是否使用cURL发送数据或是否有其他方法?
提前致谢。
干杯
答案 0 :(得分:0)
if (extension_loaded('soap'))
{
$Username = "xxxxxx";
$AccessKey = "xxxxxx";
$url = "https://xxxxx.co.uk/xxxxx/OrderRelay.svc?wsdl";
$options = array(
'authentication' => SOAP_AUTHENTICATION_BASIC,
'login' => $Username,
'password' => $AccessKey,
'trace' => 1,
'exception' => 0,
);
try
{
$client = new SoapClient($url, $options);
if($client){
$client->Post_Orders(array("unique_Id"=>"$InvoiceNo", "itemNo"=>"$itemNo","_Quantity"=>"$itemQty","waiterNo"=>"$waiterNo","tableId"=>"$tableId","salesSection"=>"$itemSection"));
}else{
echo"Failed";
}
}
catch (SoapFault $soapFault)
{
echo "SOAP REQUEST FAILED :<br>";
}
}
else
{
echo "Php SOAP extention is not available";
}