php ve webservices

3 Cevap php

Ben php yeni duyuyorum bu yüzden benimle çıplak lütfen. Ben bir wsdl dosyası var ve ben bir php sınıfından onu aramak için çalışıyorum. Ben aşağıdaki kodu kullanıyorum:

<?php

("dbconn.php") içerir;

class dataclass {

function getCountries()
{
	$connection = new dbconn();

	$sql = "SELECT * FROM tblcountries";

	$dataset = $connection -> connectSql($sql);

	return $dataset;
}

function getTest()
{
	$connection = new dbconn();

	$sql = mysql_query('CALL sp_getTest');

	$dataset =  $connection -> connectSql($sql);

	return $dataset;
}


##-------------------------------------------CUSTOMER METHODS-------------------------------------------
function registerCustomer($username,$name,$surname,$password,$email,$country,$tel)
{
	$connection = new dbconn();

	$sql="INSERT INTO tblcustomer (customer_username, customer_password, customer_name, customer_surname,
		customer_email, customer_country, customer_tel) 
		VALUES('$username','$name','$surname','$password','$email','$country','$tel')";

	$dataset = $connection -> connectSql($sql);

}



ini_set("soap.wsdl_cache_enabled", "0");
// start the SOAP server - point to the wsdl file
$webservice = new SoapServer("http://localhost/dataobjects/myWebservice.wsdl", array('soap_version' => SOAP_1_2));

// publish methods
$webservice->addFunction("getCountries");
$webservice->addFunction("registerCustomer");
// publish
$webservice->handle();

} ?>

Bana ini_set("soap.wsdl_cache_enabled", "0"); ile ilgili bir sorun vererek her zaman

Hata:

Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\Program Files\xampplite\htdocs\dataobjects\dataClass.php on line 47

3 Cevap

Ben size sınıf gövdesinde () çağrısı ini_set çünkü öyle inanıyorum. Eğer varsa dosyanın üst veya kurucusuna koy.

class dataClass
{
    function registerCustomer()
    {
       // some stuff
    }

    ini_set(/*args*/); // it's illegal to put instructions in the body of the class
}

Şimdi her şeyi görebilirsiniz. Muhtemelen hat 47 önce bir kapanış konsolu ile sınıfını kapatmak istiyor.

Sen ayrıştırıcı "0" bir dize düşüneyim, ve bir sayı değil, tırnak kaldırın lütfen!

Bu işe isterseniz Edit 1, hata bu çizgi önce, inceleme için tam kodu göndermeden lütfen olmalıdır.

Edit 2 Verdiğiniz kod sınıf içinde koşuyordu, sen ini_set ile satırından önce bir dirsek özledim.

(...) Ini_set önünde} son taşıyın

Bu arada, size bir web hizmetini çağırmak istiyorum dedi, ama başkaları tarafından davet edilebilir bir sunucu yaratıyor.

call, bir web hizmeti, böyle bir şey deneyin:

try{
	$client = new SoapClient($service, array('location' =>"http://example.org/myWebService"));
	$parameter1 = new myWebServiceParameter();
	$result = $client->myWebServiceFunction($parameter1);
} catch (Exception $e) {
	// handle errors
}

myWebServiceParameter must be any class with a member variable foreach WSDL message attribute of the same name. And myWebServiceFunction is the name of the web service method.