Yii Framework Forum: Implement Nusoap In Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Implement Nusoap In Yii I want to use NuSOAP webservice in Yii - not default webservice! Rate Topic: -----

#1 User is offline   kjashkjaskjfhkajshfkjhkjh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 03-November 11

Posted 28 March 2013 - 04:22 AM

Hello everybody,

I have a small module must be convert from PHP-core to Yii Controller.
First is simple Webservice using NuSOAP:

<?php
include "nusoap.php";
$server = new soap_server();
$server->configureWSDL('MOReceiver');
$server->xml_encoding = "utf-8";
$server->soap_defencoding = "utf-8";
$namespace = "http://canhsong.com/MO/";
$server->wsdl->schemaTargetNamespace = $namespace;
/**
 * 0: success receive
 * 1: unsuccess receive
 * 2: wrong user
 * 3: wrong password
 */
function MOReceiver($User_ID, $Service_ID, $Command_Code, $Message, $Request_ID, $username, $password) 
{
    if ($username == 'canhsong') { // Check User
        if ($password == '123qwe') { // Check Password
            // Do something here when access successful
            return 0;
        }
        else
            return 3;
    }
    else
        return 2;
}

$server->register("MOReceiver", 
                array('User_ID' => 'xsd:string', 
                        'Service_ID' => 'xds:string', 
                        'Command_Code' => 'xds:string',
                        'Message' => 'xds:string',
                        'Request_ID' => 'xds:string',
                        'username' => 'xds:string',
                        'password' => 'xds:string'),
                array('result' => 'xsd:string'),
                $namespace,
                false,
                'rpc',
                'literal',
                false);

$query = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA : '';
$server->service($query);


and the test code is:

<?php
echo "Create SOAP Client<br>";
$svTest = new SoapClient("http://canhsong.com/MO/index.php?wsdl");

echo "Call SOAP Function<br>";
$result = $svTest->MOReceiver("mrdan32","8385","DD","DD TEST","1","canhsong","123qwe");
echo "Print Return Function<br>";
print_r($svTest->__getFunctions());
echo "Print Result<br>";
print_r($result);
?>


the result is

Quote

Create SOAP Client
Call SOAP Function
Print Return Function
Array ( [0] => string MOReceiver(string $User_ID, string $Service_ID, string $Command_Code, string $Message, string $Request_ID, string $username, string $password) )
Print Result
0


Now I want to convert this code into Yii Action, I did that:
- Create an actionSoap in SiteController: call by http://canhsong.com/yii/site/soap.php
function MOReceiver($User_ID, $Service_ID, $Command_Code, $Message, $Request_ID, $username, $password) 
{
    if ($username == 'canhsong') { // Check User
        if ($password == '123qwe') { // Check Password
            // Do something here when access successful
            return 0;
        }
        else
            return 3;
    }
    else
        return 2;
}
public function actionSoap()
	{
		//$this->render('index');
		include "soap/nusoap.php";// Included right file
		$server = new soap_server();
		$server->configureWSDL('MOReceiver');
		$server->xml_encoding = "utf-8";
		$server->soap_defencoding = "utf-8";
		$namespace = "http://canhsong.com/yii/site/soap.php";
		$server->wsdl->schemaTargetNamespace = $namespace;

		$server->register("MOReceiver",
                array('User_ID' => 'xsd:string',
                        'Service_ID' => 'xds:string',
                        'Command_Code' => 'xds:string',
                        'Message' => 'xds:string',
                        'Request_ID' => 'xds:string',
                        'username' => 'xds:string',
                        'password' => 'xds:string'),
                array('result' => 'xsd:string'),
                $namespace,
                false,
                'rpc',
                'literal',
                false);

		$query = isset($HTTP_RAW_POST_DATA)? $HTTP_RAW_POST_DATA : '';
		$server->service($query);
	}


But it couldn't call the function MOReceiver, if you run the test (edit link) only stop on:

Quote

Create SOAP Client
Call SOAP Function


So I know that the actionSoap couldn't add the function MOReceiver on $server->register("MOReceiver",

Anybody could help me? Or if you use the Default Yii Webservice, let me know how to make a Webservice like the Service above:

http://canhsong.com/MO/index.php

The XML site is: http://canhsong.com/MO/index.php?wsdl
0

#2 User is offline   kjashkjaskjfhkajshfkjhkjh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 03-November 11

Posted 29 March 2013 - 11:37 AM

Anybody help me?
0

#3 User is offline   kjashkjaskjfhkajshfkjhkjh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 03-November 11

Posted 04 April 2013 - 09:52 AM

Re update last time!
0

#4 User is offline   capsuline 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 18-June 09
  • Location:Netherland

Posted 16 May 2013 - 01:18 AM

Did you finally manage?
I see you did not get help.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users