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