2016-04-12 51 views
0

Laravel'i kullanarak bir Web Hizmetine bir XML boşluğu göndermeye çalışıyorum ve web hizmetine nasıl bağlanacağını, yetki vermeyi ve gerekli olanı göndermeyi öğrenmek için uğraşıyorum veri.Laravel & PHP kullanarak bir SOAP Web Hizmetine veri gönderme

ben curl kullanmayı denedi, ama

$result // IS MY XML file 

$username = 'username' 
$password = 'password' 
$URL = 'http://xxxxxx.com; 

//setting the curl parameters. 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $URL); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS,"xmlRequest=" . $result); 
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8'); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); 
curl_exec($ch); 

if(!curl_exec($ch)){ 
    die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch)); 
} 

curl_close($ch); 

} 

olacağını yardımcı olacağını başka soru benim Kod Aşağıda

Error: "" - Code: 0

edilir alıyorum - veri göndermeyi başka yolu var mı Curl kullanmak zorunda kalmadan bir SOAP Web Servisi için?

Teşekkür ederiz Önceden

cevap

1

Evet var. SoapClient class bir göz atın: Böyle kullanabilirsiniz: laravel için this kütüphane bulunmaktadır

$options = [ 
    'trace' => true, 
    'cache_wsdl' => WSDL_CACHE_NONE 
]; 

$credentials = [ 
    'username' => 'username' 
    'password' => 'password' 
]; 

$header = new SoapHeader($NAMESPACE, 'AuthentificationInfo', $credentials); 

$client = new SoapClient($WSDL, $options); // null for non-wsdl mode 

$client->__setSoapHeaders($header); 

$params = [ 
    // Your parameters 
]; 

$result = $client->GetResult($params); 
// 'GetResult' being the name of the soap method 

if (is_soap_fault($result)) { 
    error_log("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})"); 
} 

. Denedim, sonra kendi sarmalayıcımı yazdım.

+0

laravel-soap kitaplığını kullanmayı denedim ve bir hata alıyorum. ** SOAP-ERROR: WSDL Ayrıştırma: ** bulunamadı. Bu hatayı neden olabilecek herhangi bir fikrin var mı? – jaahvicky

İlgili konular