Português Português English English

WSDL + PHP = WSDLDocument

This post was made to release the WSDLDocument, a WSDL generator in PHP to webservices.

The way how some subjects are saying about TI hides the expert developer that exists inside a lot of professionals from our area. One of these subjects is webservices. It’s easy to do a client in PHP. But to do a server it’s necessary more work because the WSDL generation. Of course there are others things to look at during the development with webservices.

WSDLDocument

Why is to make WSDL in PHP difficult? A variable in PHP change its type during the script running. The webservices needs you declare the returns’ and arguments’ type.

The goal is look out it to generate the WSDL. To do this isn’t easy, but this isn’t as hard as find mustache on Elephant. So dear, the WSDL generation may be made with two steps:

  1. Find out the type of the parameters and returns of the services;
  2. Generate the XML.

The developer who implemented each service must to describe any where the types information. No more magic, ok? We’re not mage, we’re TI professionals. A good place to put it is the method documentation. The notations help us to solve this problem and keep our code well documented. With the types information we can generate the WSDL. The WSDL generation must to follow W3C stardards.

I release today the WSDLDocument!

This library isn’t a new thing. I did it - only - to improve my knowledges and to understand the WSDL structure. Some another libraries:

As someone may see the WSDLDocument extends DOMDocument. You create a instance of this and… go planet! You have a XML in your hand. You may - for example - link a XSLT file to show a bit beautiful on the browser. I didn’t want to be intrusive and oblige you change your framework. This have to be saw as a library to be put inside your application.

Above a sample how to use this library.

<?php

// generating the wsdl
$class "MyWebserviceClass";
$url "http://mydomain.com/?class=" $class;
$wsdl = new WSDLDocument$class$url );

// showing the wsdl
echo $wsdl->saveXml();

<?php

class MyWebserviceClass
{
    
    
/**
     * Transfering complex type.
     *
     * @param Person
     * @return integer
     */
    
public function anyMethodPerson $type )
    {
        
// ...
        
return 100;
    }
    
    
/**
     * Transfering array of complex type.
     *
     * @param integer
     * @return Person[]
     */
    
public function another$quantity )
    {
        
$list = array();
        for ( 
$i 0$i $quantity$i++ )
        {
            
array_push$list, new Person() );
        }
        return 
$list;
    }
    
}

class 
Person
{
    
    
/**
     *
     * @var string
     */
    
public $name "";
    
    
/**
     *
     * @var integer
     */
    
public $children "";
    
}

I will try keep this library updated. I’m busiest this time, because this I don’t know what it’ll happen.

download the WSDLDocument here

Posted in Development, PHP | 5 Comments

“hello world” denovo

I’m very happy to announce I’m going to write some things in English here.

My friends know I’m studying English. But nobody have to read my tries, the posts will still be written in Portuguese too. I would be happy if you want to give me some tips, fell free to do so!

Thank you Vitor Choi for showing me the Babel plugin. The posts have an icon to change the language easily.

News are coming…

Posted in Misc | 5 Comments

Patterns para elementos visuais

Você precisou alguma vez justificar para seu cliente o motivo pelo qual um menu gigantesco ficaria ruim em sua aplicação?

Hélio Miranda, amigo meu, me mostrou o Interaction Design Pattern Library. É um repositório com vários padrões de elementos de interface muito interessante. O site organiza os padrões em categorias. Visualizei várias coisas boas.

Uma delas é a padronização de nomes. Não precisamos mais nos referir ao Parts Selector  como “pra-lá pra-cá” e ter que explicar que diabos é isso. O padrão está lá, e documentado.

Outra coisa coisa é a visão orientada a solução de problemas. Todo bom arquiteto (informação/interface/…) escolhe (ou faz) um pattern para a resolução de problemas. O site indica qual problema está sendo resolvido em cada um dos patterns.

Usem a abusem. See you soon!

Posted in Development | No comments
BrasilMato GrossoRondôniaDistrito Federal