wsdl2php

Welcome to wsdl2php!

This page is intended to inform about updates and current status.

1. Download the first version here (Linux only)
2. Run ./configure, make
3. Type wsdl2php -h


wsdl2php Version 0.0.1 (c) 2006 Manfred Weber
Usage: ./wsdl2php [-h] [-V] [-v] [-D] [-o ] [-s ] [-n ] [-w ] ...
-h : Print this help and exit
-V : Print version and exit
-v : See what the tool is generating as it is generating it.
-D : Print debug information
-o : Override the root directory for all emitted files
-w : URL or filename of wsdl
-s : Override Schema Namespace
-n : Override Service Namespace
-f : Override Filetype Suffix - Default is .php
-x : Register new xsl Template set - Default is php5


Here is a short example using the GoogleSearch Api:

./wsdl2php -w http://api.google.com/GoogleSearch.wsdl
This will create all the DataTypes and the Service Files in the targetNamespace which is defined by google.

The result should look like this:

GoogleSearch/
|-- DirectoryCategory.php
|-- DirectoryCategoryArray.php
|-- GoogleSearchResult.php
|-- GoogleSearchService.php
|-- ResultElement.php
|-- ResultElementArray.php
`-- port
    `-- GoogleSearchPort.php


Now why is there an extra file created "GoogleSearchPort.php" ?
wsdl2php creates for each portType a seperate layer which you can use with a factory.

PHP:
  1. ini_set('include_path','/path/to/GoogleSearch');
  2. include_once("GoogleSearchService.php");
  3. $service = GoogleSearchService::factory("GoogleSearchPort");
  4. $result = $service->doGoogleSearch( $key, $q, $start, $maxResults, $filter, $restrict, $safeSearch, $lr, $ie, $oe );

Due to the possibility of wsdl to support different kinds of porttypes, the service is called with a factory where the 1.param holds the implementation of the port. The GoogleSearch Api uses Soap, so GoogleSearchPort.php holds the php soap implementation.

PHP:
  1. $options = array('exceptions'=>'1');
  2. $service = GoogleSearchService::factory("GoogleSearchPort", $options);

You can optionally pass a 2.nd parameter which holds the options for the portType implementation.

-- Manfred

6 Comments

  1. wsdl2php » Manfred`s Diary 2006-03-14, 3:55 pm

    [...] I just finished the first version of a tool with the name wsdl2php. Like the name explains this tool creates php-code from wsdl. It is written in c and uses the libxml library. I think the result is pretty good and I am asking you to test it. [...]

  2. david 2006-04-11, 10:30 pm

    core dump on freebsd, but configure && make and wsdl2php -h works.

  3. Rahul 2006-05-12, 2:17 am

    Dear Friend,

    Heads up for your work. The tool works fine, but there is some problem in it. It seems like, its only for soap1.0 and it doesn’t work for soap1.2. While generating it gets error by saying “soap12″ not found in the templates directory.

    Here is the wsdl url, you can check it out for yourself.

    http://beta6.api.idss.msn.com/adcenterapi.asmx?WSDL

    Also, I tried to copy the same soap to saop12 and then it got success, but there are lot of files which came as empty.

    I think, it doesn’t solve the Object based wsdl.

    if you try to extract it, you will know about it.

    Thanks,
    Rahul

  4. Rahul 2006-05-12, 2:19 am

    Dear Friend,

    Heads up for your work. The tool works fine, but there is some problem in it. It seems like, its only for soap1.0 and it doesn’t work for soap1.2. While generating it gets error by saying “soap12″ not found in the templates directory.

    Here is the wsdl url, you can check it out for yourself.

    http://beta6.api.idss.msn.com/adcenterapi.asmx?WSDL

    Also, I tried to copy the same soap to saop12 and then it got success, but there are lot of files which came as empty.

    I think, it doesn’t solve the Object based wsdl.

    if you try to extract it, you will know about it.

    Thanks,
    Rahul

  5. Vinicius 2006-12-1, 1:54 pm

    I have with this problem:

    pandora:/usr/local/wsdl2php-0.0.1# ./wsdl2php -w chess.wsdl
    Creating Datatype Files done
    Segmentation Fault

    Here is the installation:

    pandora:/usr/local/wsdl2php-0.0.1# ./configure
    ^[[Cchecking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for gawk... no
    checking for mawk... mawk
    checking whether make sets $(MAKE)... yes
    checking for gcc... gcc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    checking whether we are cross compiling... no
    checking for suffix of executables...
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ANSI C... none needed
    checking for style of include used by make... GNU
    checking dependency style of gcc... gcc3
    checking for g ... g
    checking whether we are using the GNU C compiler... yes
    checking whether g accepts -g... yes
    checking dependency style of g ... gcc3
    checking how to run the C preprocessor... gcc -E
    checking for egrep... grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking arpa/inet.h usability... yes
    checking arpa/inet.h presence... yes
    checking for arpa/inet.h... yes
    checking netdb.h usability... yes
    checking netdb.h presence... yes
    checking for netdb.h... yes
    checking netinet/in.h usability... yes
    checking netinet/in.h presence... yes
    checking for netinet/in.h... yes
    checking for stdlib.h... (cached) yes
    checking for stdbool.h that conforms to C99... yes
    checking for _Bool... yes
    checking for an ANSI C-conforming const... yes
    checking for size_t... yes
    checking whether time.h and sys/time.h may both be included... yes
    checking for working strtod... yes
    checking for gethostbyname... yes
    checking for inet_ntoa... yes
    checking for memmove... yes
    checking for memset... yes
    checking for strchr... yes
    checking for xml2-config binary... yes
    checking for xml2... yes
    ./configure: line 4786: //: is a directory
    ./configure: line 4787: //: is a directory
    ./configure: line 4788: //: is a directory
    ./configure: line 4789: //: is a directory
    checking for xslt-config binary... yes
    checking for xslt... yes
    ./configure: line 4884: //: is a directory
    ./configure: line 4885: //: is a directory
    ./configure: line 4886: //: is a directory
    ./configure: line 4887: //: is a directory
    configure: creating ./config.status
    config.status: creating Makefile
    config.status: executing depfiles commands
    pandora:/usr/local/wsdl2php-0.0.1# make
    if gcc -DPACKAGE_NAME=\"wsdl2php\" -DPACKAGE_TARNAME=\"wsdl2php\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"wsdl2php\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"wsdl2php\" -DVERSION=\"0.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_NETDB_H=1 -DHAVE_NETINET_IN_H=1 -DHAVE_STDLIB_H=1 -DHAVE__BOOL=1 -DHAVE_STDBOOL_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_GETHOSTBYNAME=1 -DHAVE_INET_NTOA=1 -DHAVE_MEMMOVE=1 -DHAVE_MEMSET=1 -DHAVE_STRCHR=1 -I. -I. -I/usr/include/libxml2 -I/usr/include/libxml2 -g -O2 -MT wsdl2php.o -MD -MP -MF ".deps/wsdl2php.Tpo" -c -o wsdl2php.o `test -f 'src/wsdl2php.c' || echo './'`src/wsdl2php.c; \
    then mv -f ".deps/wsdl2php.Tpo" ".deps/wsdl2php.Po"; else rm -f ".deps/wsdl2php.Tpo"; exit 1; fi
    if gcc -DPACKAGE_NAME=\"wsdl2php\" -DPACKAGE_TARNAME=\"wsdl2php\" -DPACKAGE_VERSION=\"0.0.1\" -DPACKAGE_STRING=\"wsdl2php\ 0.0.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"wsdl2php\" -DVERSION=\"0.0.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ARPA_INET_H=1 -DHAVE_NETDB_H=1 -DHAVE_NETINET_IN_H=1 -DHAVE_STDLIB_H=1 -DHAVE__BOOL=1 -DHAVE_STDBOOL_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_GETHOSTBYNAME=1 -DHAVE_INET_NTOA=1 -DHAVE_MEMMOVE=1 -DHAVE_MEMSET=1 -DHAVE_STRCHR=1 -I. -I. -I/usr/include/libxml2 -I/usr/include/libxml2 -g -O2 -MT util.o -MD -MP -MF ".deps/util.Tpo" -c -o util.o `test -f 'src/util.c' || echo './'`src/util.c; \
    then mv -f ".deps/util.Tpo" ".deps/util.Po"; else rm -f ".deps/util.Tpo"; exit 1; fi
    gcc -g -O2 -L/usr/lib -L/usr/lib -o wsdl2php wsdl2php.o util.o -L/usr/lib -lxml2 -lz -lpthread -lm -L/usr/lib -lxslt -lxml2 -lz -lpthread -lm
    pandora:/usr/local/wsdl2php-0.0.1# ./wsdl2php -h

    wsdl2php Version 0.0.1 (c) 2006 Manfred Weber
    Usage: ./wsdl2php [-h] [-V] [-v] [-D] [-o ] [-s ] [-n ] [-w ] …

    -h Print this help and exit
    -V Print version and exit
    -v See what the tool is generating as it is generating it.
    -D Print debug information
    -o Override the root directory for all emitted files
    -w URL or filename of wsdl
    -s Override Schema Namespace - Default is generated from WSDL-Schema Definition
    -n Override Service Namespace
    -f Override Filetype Suffix - Default is
    -x Register new xsl Template set - Default is
    -t Create Testcases

    pandora:/usr/local/wsdl2php-0.0.1# ./wsdl2php -w c
    chess.wsdl config.log config.status configure configure.ac
    pandora:/usr/local/wsdl2php-0.0.1# ./wsdl2php -w c
    chess.wsdl config.log config.status configure configure.ac
    pandora:/usr/local/wsdl2php-0.0.1# ./wsdl2php -w chess.wsdl
    Creating Datatype Files done
    Falha de segmentação
    pandora:/usr/local/wsdl2php-0.0.1# ls
    acinclude.m4 chess.wsdl configure.ac install-sh missing templates
    aclocal.m4 config.log COPYING Makefile NEWS util.o
    AUTHORS config.status depcomp Makefile.am README wsdl2php
    ChangeLog configure INSTALL Makefile.in src wsdl2php.o
    pandora:/usr/local/wsdl2php-0.0.1# make check
    make: Nada a ser feito para `check’.
    pandora:/usr/local/wsdl2php-0.0.1# cd ..
    pandora:/usr/local# ls
    bin include man share wsdl2php-0.0.1
    games lib sbin src wsdl2php-0.0.1.tar.gz
    pandora:/usr/local# chmod -R 777 wsdl2php-0.0.1
    pandora:/usr/local# cd wsdl2php-0.0.1
    pandora:/usr/local/wsdl2php-0.0.1# ./wsdl2php -w chess.wsdl
    Creating Datatype Files done
    Segmentation Fault

  6. manfred.weber 2006-12-6, 5:34 pm

    Hello Vinicius, I know about this problem. Simply the code of wsdl2php is a little bit buggy. This happens when trying to create the namespaces folder. I will provide a patch for this soon.

Add a Comment