Giter Site home page Giter Site logo

php2wsdl's People

Contributors

christingruber avatar dragosprotung avatar gunmetalbackupgooglecode avatar javierabion avatar jsoumelidis avatar matias-yii avatar maxxer avatar misch717 avatar pbeernink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php2wsdl's Issues

Using array of basic data types as input / output

I have an issue declaring arrays of basic data types as input parameter or return value.
The annotations of my method are something like this:
@param int[] $array
@return string[]

I've got the following error message for the integer array:
Uncaught exception 'ReflectionException' with message 'Class int does not exist'

A possible fix might be changing line 401 within the WSDL class (addComplexTypeArray method) from:
$this->addComplexType($singularType);
to:
$this->getXSDType($singularType);

Worked for my use case, but I'm not sure if it might cause problems for other ones.

And I also found a minor matter in this context:
As basic data types are start with a lowercase i have changed line 394 from
$xsdComplexTypeName = 'ArrayOf' . self::typeToQName($singularType);
to
$xsdComplexTypeName = 'ArrayOf' . ucfirst(self::typeToQName($singularType));
as the name for a basic data type should be ArrayOfString instead of ArrafOfstring.

Your class saved me a lot of time (and nerves).
Thank you for that...

Usage oh php2wsdl

I not use one php framework and have never used composer to install php packeges.
Now on my linux box i have installed composer and i go to my project dir and exec

$ composer require php2wsdl/php2wsdl

this create one dir structure:
./vendor
--- composer

       ----- php2wsdl

       ------ wingu

autolad.php

In the file mysoapclass.php i insert

require DIR . '/vendor/autoload.php';

and at end of this file i insert:

line 261-268

$class = 'ibr';

$serviceURI = "http://127.0.0.1/soap/finale";
$wsdlGenerator = new PHPClass2WSDL($class, $serviceURI);
// Generate thw WSDL from the class adding only the public methods that have @soap annotation.
$wsdlGenerator->generateWSDL(true);
$wsdlXML = $wsdlGenerator->dump();

file_put_contents ( 'finale.wsdl', $wsdXML );

running 'php mysoapclass.php' i get

PHP Fatal error: Uncaught Error: Class 'PHPClass2WSDL' not found in /var/www/html/soap/finale/mysoapclass.php:263

I have try some require/include modification without success.

Thank's for your reply

Gian Luca

php 8.0.3 yields fatal error in getConstants()

I am trying to use this package with php 8.0.3 and I get the following fatal error:

PHP Fatal error: Declaration of Wingu\OctopusCore\Reflection\ReflectionClass::getConstants() must be compatible with ReflectionClass::getConstants(?int $filter = null) in /var/www/html/php2wsdl-2019-10-17/vendor/wingu/reflection/src/ReflectionClass.php on line 234

probably due to stricter type checking in php.

Will it support SOAP 1.2 ?

Since the changes are not that big, would it be nice to add this support...

SOAP 1.1 uses namespace http://schemas.xmlsoap.org/wsdl/soap/
SOAP 1.2 uses namespace http://schemas.xmlsoap.org/wsdl/soap12/

In SOAP 1.2:

<binding name="EmployeeServiceImplPortBinding" type="tns:EmployeeServiceImpl">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="findEmployeeById">
    <soap12:operation soapAction=""/>
    <input><soap12:body use="literal"/></input>
    <output><soap12:body use="literal"/></output>
</operation><operation name="create">
    <soap12:operation soapAction=""/>
    <input><soap12:body use="literal"/></input>
    <output><soap12:body use="literal"/></output>
</operation>
</binding>

in SOAP 1.1:

<binding name="EmployeeServiceImplPortBinding" type="tns:EmployeeServiceImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="findEmployeeById">
    <soap:operation soapAction=""/>
    <input><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></input>
    <output><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></output>
</operation><operation name="create">
    <soap:operation soapAction=""/>
    <input><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></input>
    <output><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></output>
</operation>
</binding>

Basically the URL changed and the tag from soap to soap12.

Creating complex type of an array of basic data types

Hi Dragos,

sorry for opening a new issue, but I don't found your contact email, otherwise I had contacted you directly. First, thanks for your fast support. Unfortunately your changes don't work for my scenario.
Now arrays of basic data types are not resulting in complex types anymore, as they are handled as basic array.

<message name="testMethodIn">
    <part name="para1" type="soap-enc:Array"/>
    <part name="para2" type="soap-enc:Array"/>
</message>
<message name="testMethodOut">
    <part name="return" type="soap-enc:Array"/>
</message>

That's ok for php and his dynamic typing, but are more strict languages would like to know what data type is stored within the array.

My corresponding method for this example:

     /**
     * @param string[] $para1
     * @param bool[] $para2
     * @return string[]
     */
    public function testMethod($para1, $para2){
        return array("ret1","ret2");
    }

I think the resulting wsdl parts It should look something like that:

  1. the data definition
<xsd:complexType name="ArrayOfString">
    <xsd:complexContent>
        <xsd:restriction base="soap-enc:Array">
            <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="xsd:string[]"/>
        </xsd:restriction>
    </xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ArrayOfBool">
    <xsd:complexContent>
        <xsd:restriction base="soap-enc:Array">
            <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="xsd:bool[]"/>
        </xsd:restriction>
    </xsd:complexContent>
</xsd:complexType>
  1. the message definitions
<message name="testMethodIn">
    <part name="para1" type="tns:ArrayOfString"/>
    <part name="para2" type="tns:ArrayOfBool"/>
</message>
<message name="testMethodOut">
    <part name="return" type="tns:ArrayOfString"/>
</message>

I have changed the addComplexTypeArray method to achieve this.

protected function addComplexTypeArray($singularType, $type)
    {
        $isBasicDataType = isset(self::$XSDTypes[strtolower($singularType)]);
        $nsPrefix = $isBasicDataType ? 'xsd' : 'tns';

        $xsdComplexTypeName = 'ArrayOf' . ucfirst(static::typeToQName($singularType));
        $xsdComplexType = 'tns:' . $xsdComplexTypeName;

        // Register type here to avoid recursion.
        $this->addType($type, $xsdComplexType);

        // Process singular type using DefaultComplexType strategy.
        if(!$isBasicDataType){
            $this->addComplexType($singularType);
        }

        // Add array type structure to WSDL document.
        $complexType = $this->dom->createElement('xsd:complexType');
        $complexType->setAttribute('name', $xsdComplexTypeName);

        $complexContent = $this->dom->createElement('xsd:complexContent');
        $complexType->appendChild($complexContent);

        $xsdRestriction = $this->dom->createElement('xsd:restriction');
        $xsdRestriction->setAttribute('base', 'soap-enc:Array');
        $complexContent->appendChild($xsdRestriction);

        $xsdAttribute = $this->dom->createElement('xsd:attribute');
        $xsdAttribute->setAttribute('ref', 'soap-enc:arrayType');
        $xsdAttribute->setAttribute('wsdl:arrayType', $nsPrefix.':' . static::typeToQName($singularType) . '[]');
        $xsdRestriction->appendChild($xsdAttribute);

        $this->schema->appendChild($complexType);

        return $xsdComplexType;
    }

Hopefully it also works as desired with objects.
If you have any example for an object, that is not working properly with this changes feel free to inform me.

looks like we got no XML document

Hi,

with your library i generated WSDL file from simple PHP class. But when Im trying to connect to SoapServer via SoapClient i had error "looks like we got no XML document".

See github: https://github.com/Kcko/wsdl

Can you help me? I spent a many hours on google when i tried a many solutions => WITHOUT SUCCESS.

Missing Type

Could you please add decimal type to static $XSDTypes. Thanks.

Problema webservice xml

Salutare Dragoș ! Îmi cer scuze că te deranjez tocmai aici dar e singurul loc în care văd că mai ești activ! Te rog din suflet să-mi dai un mail către [email protected] sau să-mi raspunzi aici cu o adresă de-a ta sau orice altceva prin care să putem lua legătura în legătură cu un webservice SOAP. Ești singurul pe care l-am văzut că lucrează cu așa ceva și cu care aș putea lua legătura, bineînțeles, contra cost. Îți mulțumesc mult și poți șterge acest thread!

Cu respecte,
Eduard!

Problem point: class initialization verification

Description: This is my first contact with WebService. I think if an interface is used to define external services, the code structure may be better. I try to modify the code and find that the execution result is normal.
I hope to get a reply.

How do i suppose to add header to a specific method ?

I want to add header like <soap:header message="" part="" use="encoding"/>

<operation name="addRecipient">
      <soap:operation soapAction="https://gateway.ekomiapps.de/soap#addRecipient"/>
      <input>
<!-- HERE -->
        <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="namespace"/>
      </input>
</operation>

DOMDocument::loadXML() error

This sample code does not work. In an XML file URL is not escaped correctly.

$className = 'app\modules\api\controllers\ClientController';
$serviceUrl = 'http://mysite.com/index.php?r=api/client/service&ws=1';

$wsdlGenerator = new PHPClass2WSDL($className, $serviceUrl);
$wsdlGenerator->generateWSDL(true);
$wsdlGenerator->dump();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.