Forums / Extensions / Soap/Wsdl loginhandler

Soap/Wsdl loginhandler

Author Message

Nabran Aboubacar

Tuesday 22 December 2009 3:44:07 am

Hi,

I'm begining with Ez

Realy good work, powerfullllframework

But to deal whith webservice it's not easy.

I'm trying to activate user login truth a wsdl webservice (the users are in an SQL server 2005)

The WSDL works fine with other systems but not ez.

In forums i saw the ezsoap is not fully compatible with wsdl.

Some topic recommend Nusoap or ggwebservices.But no doc,no explanation no "how to" to create my login function to consume a webservice.

I'll greatfull if i can have some help:

1-which file do i need

2-in which folder to put them (kernel/.... or extension)

3-what Do i have to activate? ( CURL in php.ini ....)

MyConfig:

  • Windows+Xampp
  • Php5
  • EZ 4.2

Thanks

Gaetano Giunta

Tuesday 22 December 2009 5:44:45 pm

make sure you have php soap extension installed. curl is a bonus, and needed you have to use https.

get the ggwebservices extension

decompress it in the 'extension' folder

go to admin interface, 'setup/extensions' page and activate it

create somewhere an override file for wsproviders.ini, where you put the ip address and details of your soap server and give it a name that you will later used in your code

create an extension, inside that create a new login handler. Take code from kernel/calsses/datatypes/ezuser/ezldapuser.php as an example. If you do not find docs about creating an extension with a login handler, take an existing extension that does that as an example (search for it on projecst.ez.no)

the code for the login handler will need at some point to use the static method ggeZWebservicesClient::send() to call the soap service

Principal Consultant International Business
Member of the Community Project Board

Nabran Aboubacar

Wednesday 23 December 2009 8:47:22 am

Thanks gaetano :-) really appriciate ur help.I feel less alone

I try all this tonight.
I've got you know.

Nabran Aboubacar

Monday 11 January 2010 1:00:45 pm

Hello
I am back
Thank you GG I finally wrote a php client that works well with my .Net web service, I can retrieve the data for each user in the sql server.

But I feel it is necessary that the user exit in DB ez.
What is contentobject and Row and ezuser In EZsystem ? 'cause my function returns a user valid according to ezuser class attributes but it doesn't works.

Some tracks?

Thanks for ur help :-)

Gaetano Giunta

Friday 18 June 2010 6:14:03 am

Ezcontentobject and ezuser are technically subclasses of the ezpersistentobject class (at the php level).

At the template level, they have a different definition - you can find it in the online docs at http://ez.no/doc/ez_publish/technical_manual/4_x/reference/objects.

You can convert the 'php-level' objects to their equivalent 'template-level' definition using a php function found in the ggxmlview or ezwebservicesapi extension - it is probably closer to what you want to expose to the outside world

Principal Consultant International Business
Member of the Community Project Board

namita varshney

Sunday 17 October 2010 10:26:06 pm

Can i have more information regarding ggwebservices.

Thanks

Heath

Monday 18 October 2010 6:14:33 am

Namita,

Welcome to the eZ Publish Community!

Check out the ggwebservices project, http://projects.ez.no/ggwebservices

And other related documention.

http://svn.projects.ez.no/ggwebservices/trunk/extension/ggwebservices/INSTALL

http://svn.projects.ez.no/ggwebservices/trunk/extension/ggwebservices/README

Cheers,

Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Gaetano Giunta

Monday 18 October 2010 1:28:08 pm

@Namita: if the docs that Heath linked to are not enough, feel free to ask more specific questions here

Principal Consultant International Business
Member of the Community Project Board

namita varshney

Monday 18 October 2010 11:29:17 pm

Thanks for ur help.

namita varshney

Tuesday 19 October 2010 12:05:38 am

"

Can i have an example of ggwebservices.

Thanks for ur help.

"

namita varshney

Tuesday 19 October 2010 6:12:36 am

XMLRPC call FAILED!

 

Fault code: [2] Reason: 'Invalid return payload: enable debugging to examine incoming payload (XML error at line 1, check URL)'

Can u say me about this error.

Gaetano Giunta

Tuesday 19 October 2010 1:01:12 pm

This error means that the xmlrpc client received something back from the server that is not valid xml. Most likely you are using a wrong url for your xmlrpc server, or you have some authentication problem.

To get more information about what is going on:

- increase the logging level, overriding the value for generalSettings/Logging in wsproviders.ini (set it to info)

- look at the log file: var/$siteaccess/log/webservices.log

Principal Consultant International Business
Member of the Community Project Board

namita varshney

Tuesday 19 October 2010 9:57:45 pm

XMLRPC call FAILED!

 

Fault code: [5] Reason: 'Didn't receive 200 OK from remote server. (HTTP/1.0 500 Internal Server Error)'

Can u say me about this error...

namita varshney

Tuesday 19 October 2010 10:30:13 pm

<?php
// include client classes
include_once( "/var/www/OSCAR/extension/ggwebservices/classes/ggxmlrpcclient.php" );
include_once( "/var/www/OSCAR/extension/ggwebservices/classes/ggxmlrpcrequest.php" );
include_once( "/var/www/OSCAR/extension/ggwebservices/classes/ggxmlrpcresponse.php" );
include_once( "/var/www/OSCAR/extension/ggwebservices/classes/ggwebservicesclient.php" );
// create a new client
$client = new ggXMLRPCClient("localhost","/OSCAR/extension/ggwebservices/classes/ezserver.php","80");
$namespace = "http://soapinterop.org/";
$request = new ggXMLRPCRequest("addNumbers");
$request->addParameter("valueA", 47);
$request->addParameter("valueB", 45);
// send the request to the server and fetch the response
$response = $client->send($request);
print_r($response);
// check if the server returned a fault, if not print out the result
if ( $response->isFault() )
{
print( "SOAP fault: " . $response->faultCode(). " - " . $response->faultString() . "" );
}
else
{
print( "Returned SOAP value was: \"" . $response->value() . "\"" );
}


?>

this my client side code can u say what is the problem in this code.

<?php
include_once( "/var/www/OSCAR/extension/ggwebservices/classes/ggxmlrpcserver.php" );
include_once( "/var/www/OSCAR/extension/ggwebservices/classes/ggxmlrpcrequest.php" );
$server = new ggXMLRPCServer();
$server->registerFunction( "addNumbers", array( "valueA" => "int", "valueB" => "int"));
$server->processRequest();
function addNumbers($valueA, $valueB)
{

$return = $valueA + $valueB;
settype( $return, "int" );
return $return;
}

?>

admin side code.

Can u say what is the problem in this code.

By writing logging='info' its not creating the log file.

namita varshney

Friday 22 October 2010 5:14:57 am

How can i integrate ggwebservices in ASP.NET?

Gaetano Giunta

Friday 22 October 2010 9:34:37 am

@namita: I am under the impression that you are trying to use the ggwebservices code outside of the scope of the eZ Publish application.

If it is so, I am afraid to tell you that this is not within the goals of ggwebservices: it has been developed as an extension to the eZPublish CMS, and there is no guarantee at all that it will ever work if used standalone. It might, but it also might not - and I cannot promise to have any time to dedicate to fix any errors you encounter for such a use case.

In particular, the webservices client classes might work, but the webservices server classes need an eZPublish server to work at all.

If you just want to execute xmlrpc or jsonrpc calls, or received those calls in a php app outside of eZPublish the phpxmlrpc extension available of http://phpxmlrpc.sourceforge.net might be a better fit.

If you want to execute or receive soap calls in a php app outside of eZPublish, the NuSOAP extension or simply the php native soap support might be a better fit.

Last but not least, answering to the question "How can i integrate ggwebservices in ASP.NET?": surely not by using classes that have XMLRPC in their name. Try using the ones that have SOAP in it.

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Friday 22 October 2010 9:53:53 am

Ok, here is the sample code with a working XMLRPC client, outside the context of eZ Publish. Please note that there is no logging whatsoever done by the client in this case, as the logging is only implemented by the ggeZWebservicesClient client

<pre>
<?php
/**
 * Sample xmlrpc client that uses the ggws classes
 * The server endpoint in use is the public one of the phpxmlrpc.sourceforge.net lib
 */

// include client classes (this is done by autload when within an eZP context)
include_once( "ggwebservices/classes/ggwebservicesclient.php" );
include_once( "ggwebservices/classes/ggxmlrpcclient.php" );
include_once( "ggwebservices/classes/ggwebservicesrequest.php" );
include_once( "ggwebservices/classes/ggxmlrpcrequest.php" );
include_once( "ggwebservices/classes/ggwebservicesresponse.php" );
include_once( "ggwebservices/classes/ggxmlrpcresponse.php" );
include_once( "ggwebservices/classes/ggwebservicesclient.php" );

// create a new client
$client = new ggXMLRPCClient("phpxmlrpc.sourceforge.net", "/server.php", "80");
// define the request
$request = new ggXMLRPCRequest("examples.addtwo", array(47, 45));

// send the request to the server and fetch the response
$response = $client->send($request);

// check if the server returned a fault, if not print out the result
if ( $response->isFault() )
{
    print( "Fault: " . $response->faultCode(). " - \"" . $response->faultString() . "\"");
}
else
{
    print( "Returned value was: \"" . $response->value() . "\"" );
}

?>

The difference wrt your example is that you should not use named parameters for xmlrpc, as the protocol uses positional ones.

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Friday 22 October 2010 10:03:05 am

And here is the working server - basically your code was fine

<?php
/**
 * Sample xmlrpc server that uses the ggws classes
 */

include_once( "ggwebservices/classes/ggwebservicesserver.php" );
include_once( "ggwebservices/classes/ggxmlrpcserver.php" );
include_once( "ggwebservices/classes/ggwebservicesrequest.php" );
include_once( "ggwebservices/classes/ggxmlrpcrequest.php" );
include_once( "ggwebservices/classes/ggwebservicesresponse.php" );
include_once( "ggwebservices/classes/ggxmlrpcresponse.php" );
include_once( "ggwebservices/classes/ggwebservicesfault.php" );

$server = new ggXMLRPCServer();
$server->registerFunction( "examples.addtwo", array( "valueA" => "int", "valueB" => "int" ) );
$server->processRequest();

function examples_addtwo($valueA, $valueB)
{
    $return = (int)$valueA + (int)$valueB;
    return $return;
}
 
?>

To test if there is any fatal errors, just browse to the server page with a browser. If you get an xml response with an error message, it's ok. If you get a blank page or a php errpr msg, it is not.

NB: a visual debugger (ie. xmlrpc client) is available within the eZ Publish administration interface, when you use the extension within the CMS

Principal Consultant International Business
Member of the Community Project Board

Gaetano Giunta

Friday 22 October 2010 10:14:37 am

And here is an example of a working soap client that interacts with a server written in asp.net

<pre>
<?php
/**
 * Sample soap client that uses the ggws classes
 * The server endpoint in use is the public one from mssoapinterop.org
 */

// include client classes (this is done by autload when within an eZP context)
include_once( "ggwebservices/classes/ggwebservicesclient.php" );
include_once( "ggwebservices/classes/ggphpsoapclient.php" );
include_once( "ggwebservices/classes/ggwebservicesrequest.php" );
include_once( "ggwebservices/classes/ggphpsoaprequest.php" );
include_once( "ggwebservices/classes/ggwebservicesresponse.php" );
include_once( "ggwebservices/classes/ggphpsoapresponse.php" );
include_once( "ggwebservices/classes/ggwebservicesclient.php" );

// create a new client
$client = new ggPhpSOAPClient("mssoapinterop.org", "/asmx/simple.asmx", 80, null, 'http://mssoapinterop.org/asmx/simple.asmx?WSDL' );
// NB: this also works:
//$client = new ggPhpSOAPClient(null, null, null , null, 'http://mssoapinterop.org/asmx/simple.asmx?WSDL');

// define the request
$request = new ggPhpSOAPRequest("echoInteger", array(123));

// send the request to the server and fetch the response
$response = $client->send($request);

// check if the server returned a fault, if not print out the result
if ( $response->isFault() )
{
    print( "Fault: " . $response->faultCode(). " - \"" . $response->faultString() . "\"");
}
else
{
    print( "Returned value was: \"" . $response->value() . "\"" );
}

?>

Principal Consultant International Business
Member of the Community Project Board

namita varshney

Sunday 24 October 2010 11:41:27 pm

my server.php is

<?php
include_once( "ggjsonrpcserver.php" );
$server = new ggJSONRPCServer();
$server->registerFunction( "addNumbers", array( "valueA" => "integer", "valueB" => "integer"),"integer");
$server->processRequest();
function addNumbers($valueA, $valueB)
{
$return = (int)$valueA + (int)$valueB;
return $return;
}
?>

When i add parameters in payload in visual ws debugger in jsonrpc

as <param>
<value><int>45</int></value>
</param>
<param>
<value><int>78</int></value>
</param>

then, i got a error.

{"result":null,"error":{"faultCode":-201,"faultString":"Request received from client is not valid according to protocol format"},"id":null}

And if i run this page from browser it ask for save the page.

Thanks