c# call yii webservice

Hello

recently I follow yii guide to create a webservice, code like below:


public function actions()

	{

		return array(

			//

			'contact'=>array(

                'class'=>'CWebServiceAction',

                /*'classMap'=>array(

                    'Post'=>'Post',  // or simply 'Post'

                ),*/

            ),

		);

	}


public function login($userName,$password)

	{

		$username=strtolower($userName);

		$criteria=new CDbCriteria;

		$criteria->select='*';

		$criteria->condition='LOWER(userName)=?';

		$criteria->params=array($username);//userType:1 means admin role

		$user=User::model()->find($criteria);

		if($user==null)

			return false;		

		else if(!$user->validatePassword($password))

			return false;

		else 

		{

			return true;

		}

	}

I run PHP test script , the webservice can be called and executed.

Then I create c# winform by using visual studio 2010 and .net2.0 and use the add web reference to add the webservice.




AccessServiceControllerService service = new AccessServiceControllerService();

bool ret = service.login(identity.userName,identity.password);



but the code always throws the exception "Client found response content type of ‘text/xml’, but expected ‘text/xml’.

The request failed with an empty response."

I use fiddle to track, found the httpresponse code is 200.

Does anyone can help me? Or please provides your code to reference.

thanks in advance

Tim

Nobody meet the same problems?

I did not have any similar experience… but as you are getting the message "… empty response"… could be that "return false" is interpreted as empty…

Try first with some values… try to echo some text and check if c# is getting that…

Hi Mdomba

I have tried that, return 1 or -1 ,but still get same error message. anyway, thanks a lot for your reply.

Tim