1

I have a wsdl file and i am trying to call it from a php class. I am using the following code:

<?php

include ("dbconn.php");

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();

} ?>

It is all the time giving me a problem with ini_set("soap.wsdl_cache_enabled", "0");

The error is:

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

7
  • 1
    can you please post dataClass.php ? Your Source code looks ok. Commented Nov 4, 2009 at 13:44
  • So what do you have on and around line 47? Because this ini_set is certainly now giving that error, it must be something before it. Commented Nov 4, 2009 at 13:44
  • Yes, please give a look at line 47. In fact, this should be re-tagged "line 47". Commented Nov 4, 2009 at 13:45
  • line 47: is the ini_set(... Before the ini_set(... there are functions such as register and get countries nothing more. they work fine if connected to the webpage eliminating the webservice. tried also to remove the 0 between "" but still with same problem Commented Nov 4, 2009 at 13:52
  • Can you post the few lines before line 47? Hit "edit". It's 4 spaces indent for code. Commented Nov 4, 2009 at 13:55

3 Answers 3

1

I believe it is because you have ini_set() call in the body of your class. Put it at the top of the file or in the constructor if you have one.

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

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

Now I see the whole thing. You probably want to close the class with a closing backet before line 47.

Sign up to request clarification or add additional context in comments.

Comments

0

You let the parser think "0" is a string, and not a number, please remove the quotes!

Edit 1 If that wouldn't work, your error must be before that line, please post the full code for review.

Edit 2 The code you provided was running inside the class, you miss a bracket before the line with ini_set.

Comments

0

Move the last } in front of ini_set(...)

By the way, you said you want to call a web service, but you are creating a server which may be called by others.

To call a web service, try something like this:

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.