Adobe Flex with Struts 2 using HttpService

July 18th, 2010 admin Posted in Open source, Web Services No Comments »

Using HttpService is the easiest way in which you can integrate Adobe Flex and Struts 2. As an example I will show you how you can create a registration form in Adobe Flex which calls a struts 2 action to create new users. Note that this example is very simple and for demonstration purposes. I am not adding any validation in flex and not even creating the users in a database. All I show you is how you can pass data between flex and struts. Read the rest of this entry »

AddThis Social Bookmark Button

WSDL Generation with WSF/PHP - Arrays and Complex types

March 16th, 2008 admin Posted in Web Services No Comments »

When you are working on code first approach you want to derive the contract WSDL from the code that you already have for the Web Service.

If you may have worked on Java or .NET Web Services you already familiarized with this approach. PHP developers are also provided the opportunity to work on this approach with WSF/PHP. You only need to give a simple introduction for your service operations and their parameter types as annotations, and you will get the WSDL generated in a flash.

Here is how you will put the annotations for a simple operation like add. Read the rest of this entry »

AddThis Social Bookmark Button

How to Return non associative arrays with new soap

March 16th, 2008 admin Posted in Web Services No Comments »

Lets assume this is the data I want to return

array(3) {
[”data”] => array(2) {
[0] => string(5) “abc”
[1] => string(3) “def”
}
[”successful”] => bool(true)
[”message”]=> string(49) “Transaction successful.”
}

Here are the 2 complex types I created

The first one is the array for the data element
$server -> wsdl ->
addComplexType(”return_data_array_multi”
, “complexType”
, “array”
, “”
, “SOAP-ENC:Array”
, array()
, array(array(”ref”
=> “SOAP-ENC:arrayType” , “wsdl:arrayType” =>
“xsd:string”))
, “xsd:string”);

The second one is the structure to hold the data,
success and message
$server -> wsdl -> addComplexType(”return_data”
, “complexType”
, “struct”
, “all”
, “”
, array(”data” =>
array(”name” => “data” , “type” =>
“tns:return_data_array_multi”)
, “successful”
=> array(”name” => “successful” , “type” =>
“xsd:boolean”)
, “message” =>
array(”name” => “message” , “type” => “xsd:string”)));

Hope this helps someone else

AddThis Social Bookmark Button

Creating a web service and WSDL using NuSOAP

March 16th, 2008 admin Posted in Web Services No Comments »

Well if you have followed the previous post on using NuSOAP to create an amazon web service then you might be interested in using NuSOAP to create a web service of your own (i.e. a server component rather than a client component). I decided to create one myself to allow me to create a .Net application to help me maintain my walks database. Read the rest of this entry »

AddThis Social Bookmark Button

Automatically Generating WSDL with NuSOAP

March 15th, 2008 admin Posted in Web Services 1 Comment »

As mentioned previously, current Web Services do almost always use WSDL. Writing WSDL manually is a real pain and very error-prone, but most serious Web Services implementations for PHP can create WSDL automatically. However, because PHP is no strongly typed language, they need some help.

To do so with NuSOAP, the code from the previous section must be expanded a bit. First, a method configureWSDL() must be called to provide the name and the namespace of the service. Then, the signature of the method must be provided (which parameters go in, which go out). Then, the server is started. However, this time whether $HTTP_RAW_POST_DATA is set is checked or not. This is because when it is not set, the user has made a GET request, so there might be a chance that he just wants the WSDL description.

A WSDL-enabled Web Service with NuSOAP (wsdl-nusoap-server.php)
<?php
  require_once ‘nusoap.php’;

  $soap = new soap_server;
  $soap->configureWSDL(’AddService’, ‘http://php.
    hoshmand.org/’);
  $soap->wsdl->schemaTargetNamespace = ‘http://
    soapinterop.org/xsd/’;
  $soap->register(
    ‘add’,
    array(’a’ => ‘xsd:int’, ‘b’ => ‘xsd:int’),
    array(’c’ => ‘xsd:int’),
    ‘http://soapinterop.org/’
  );
  $soap->service(isset($HTTP_RAW_POST_DATA) ?
    $HTTP_RAW_POST_DATA : ”);

  function add($a, $b) {
    return $a + $b;
  }
?>

Read the rest of this entry »

AddThis Social Bookmark Button

Webservice Search Domain See Information Domain

March 12th, 2008 admin Posted in Web Services No Comments »

If you check domain is already registered then you see information domain.

Webservice Search Domain

Tool check domain Web Services by nusoap

Add code

Input: domain
Output: string information domain

Download nusoap v 1.94

<?php
require_once(’../lib/nusoap.php’);
$client = new soapclient(’http://www.kingf1.com/xyz/samples/server_checkdomain.php’);

$return = $client->call(’infoDomain’, array(’name’=>”google.com.vn”));

echo”<font color=\”#FF0000\”> Domain google.com.vn is already registered</font>”;
echo”<h2>Result</h2>”;
print($return);
?>

Demo information domain
http://www.kingf1.com/xyz/samples/infodomain.php

Demo full

http://www.kingf1.com/xyz/samples/demo.php

AddThis Social Bookmark Button

Web Service Search domain by nusoap

March 7th, 2008 admin Posted in Web Services 2 Comments »

Webservice Search domain

Tool check domain Web Services by nusoap

ex:

input: kingf1.com;

ouput: kingf1.com 0 // is already registered

ouput: kingf1.com 1 // is not registered

Download nusoap v 1.94

Add code

<?php
require_once(’../lib/nusoap.php’);
$client = new soapclient(’http://www.kingf1.com/xyz/samples/server_checkdomain.php’);
/* if one domain */
$return = $client->call(’checkDomain’, array(’name’=>”kingf1.com”));
/*else*/
//$return = $client->call(’checkDomain’, array(’name’=>array(’kingf1.com’,'kingf1.net’,'kingf1.org’)));
echo”<h2>Result</h2>”;
foreach ($return as $value)
{
print_r($value);
echo “<br />”;
}
?>

Demo:

http://www.kingf1.com/xyz/samples/demo.php

AddThis Social Bookmark Button

Introduction to NuSOAP

March 6th, 2008 admin Posted in Web Services No Comments »

NuSOAP is a group of PHP classes that allow developers to create and consume SOAP web services. It does not require any special PHP extensions. The current release version (0.6.7) of NuSOAP at the time this was written (03-November-2004), supports much of the SOAP 1.1 specification. It can generate WSDL 1.1 and also consume it for use in serialization. Both rpc/encoded and document/literal services are supported. However, it must be noted that NuSOAP does not provide coverage of the SOAP 1.1 and WSDL 1.1 that is as complete as some other implementations, such as .NET and Apache Axis.This document describes how to obtain and install NuSOAP, then provides some samples to illustrate the capabilities of NuSOAP. It is by no means an exhaustive description of NuSOAP, but it is hopefully enough to get any PHP coder started. Programming with NuSOAP follows this up with more complex samples.Installation
Hello, World
Debugging
Request and Response
Resources

Installation

The NuSOAP project is hosted by SourceForge. You can obtain NuSOAP either as a downloadable release or from the CVS tree of the NuSOAP project on SourceForge. A browser-based CVS interface is provided. As an example, you can obtain version 1.81 of nusoap.php with the following URL:

http://cvs.sourceforge.net/viewcvs.py/*checkout*/nusoap/lib/nusoap.php?rev=1.81. You can start working with the version of the code you choose. I have run the samples below with version 1.81.

Once you have downloaded a copy of nusoap.php, you simply need to place it in your code tree so that you can include it from your PHP code. Some users put in it a separate lib directory. For my examples, I placed it in the same directory as the sample code itself.

Read the rest of this entry »

AddThis Social Bookmark Button