Results 1 to 8 of 8
  1. #1

    Default Need Help: Array in WSDL


    Hi guys,

    Ganiha ra ko sige ug sulbad ani pero wala pa jud nako na sulbad. Basin naa mo idea usaon ni siya.

    Basically akong gustong buhaton is to return an array of strings.

    mao ni akong WSDL file:
    Code:
    <?xml version="1.0"?>
    <definitions name="DemoService" targetNamespace="urn:DemoService" 
        xmlns:typens="urn:DemoService" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
        xmlns="http://schemas.xmlsoap.org/wsdl/">
        <types>
            <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:TreonService">
                <xsd:complexType name="ArrayOfString">
                    <xsd:sequence>
                        <xsd:element name="item" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:schema>
        </types> 
        <message name="ArrayOfStringMessage">
            <part name="return" type="typens:ArrayOfString" />
        </message>
        <portType name="DemoServicePort">
            <operation name="ReturnArrayOfString">
                <output message="typens:ArrayOfStringMessage"/>
            </operation>
        </portType>
        <binding name="DemoServiceBinding" type="typens:DemoServicePort">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
            <operation name="ReturnArrayOfString">
                <soap:operation soapAction="urn:DemoServiceAction" />
                <output>
                    <soap:body use="encoded" namespace="urn:DemoService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </output>
            </operation>
        </binding>
        <service name="DemoServiceEndpoint">
            <port name="DemoServicePort" binding="typens:DemoServiceBinding">
                <soap:address location="http://localhost/demo.php" />
            </port>
        </service>
    </definitions>
    then mao ni akong server iplementation. php akong gamit:
    Code:
    <?php
       
       function ReturnArrayOfString()
       {
         return array('asdf', 'asdf', 'asdf');
       }
       
       $opts = Array();
       $opts['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP;
       $server = new SoapServer('demo.wsdl', $opts);
       $server->addFunction('ReturnArrayOfString');
       $server->handle();
       
    ?>
    Mao ni akong client
    Code:
    <?php
        ini_set('soap.wsdl_cache_ttl', 0);
        
       $client = new SoapClient('http://localhost/demo.wsdl');
       $res    = $client -> ReturnArrayOfString();
       var_dump($res);
    
    ?>
    ang error mugawas kay:
    Code:
    Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Procedure 'ReturnArrayOfString' not present in ...
    Taba-ngi ko ug debug please. Bag.o pa man ko sa ani so if naa moy ika-suggest I would love to hear it.


    Best regards,
    Ish

  2. #2

    Default Re: Need Help: Array in WSDL

    wa may problema sa code. asa na na-save ang files ug unsa ang ilang exact nga filename/path/url? mao ni...

    http://localhost/demo.wsdl -> xml/wsdl
    http://localhost/demo.php -> server implementation
    http://localhost/client.php -> client implementation

    make sure sa imong xml nga sakto ang soap address location kay kinghanlan mao na ang script url sa server-side implementation (http://localhost/demo.php) then sa client kay inig instantiate nimo sa soap client make sure to pass the correct wsdl url (http://localhost/demo.wsdl)

    i tested your code, working man.

  3. #3

    Default Re: Need Help: Array in WSDL

    I think there something wrong sa configuration nako. Yesterday dili siya working pero karon working na siya. Then if I try to change the names or types mubalik siya adtong error nga akong first na encounter. Any insights?

  4. #4

    Default Re: Need Help: Array in WSDL

    It's seems ni gana na. ang problem kay i cache sa server ang wsdl so pag add nako sa option nga dili i cache na ok na siya. Mao ni final nga code nako:

    demo.wsdl
    Code:
    <?xml version="1.0"?>
    <definitions name="DemoService" targetNamespace="urn:DemoService" 
        xmlns:typens="urn:DemoService" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
        xmlns="http://schemas.xmlsoap.org/wsdl/">
        <types>
            <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:TreonService">
                <xsd:complexType name="Object">
                    <xsd:all>
                        <xsd:element name="ObjectID" type="xsd:int" />
                        <xsd:element name="ObjectName" type="xsd:string" />
                    </xsd:all>
                </xsd:complexType>
                <xsd:complexType name="ArrayOfObject">
                    <xsd:sequence>
                        <xsd:element name="item" type="typens:Object" minOccurs="0" maxOccurs="unbounded" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:schema>
        </types> 
        <message name="ArrayOfObjectMessage">
            <part name="return" type="typens:ArrayOfObject" />
        </message>
        <portType name="DemoServicePort">
            <operation name="ReturnArrayOfObject">
                <output message="typens:ArrayOfObjectMessage"/>
            </operation>
        </portType>
        <binding name="DemoServiceBinding" type="typens:DemoServicePort">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
            <operation name="ReturnArrayOfObject">
                <soap:operation soapAction="urn:DemoServiceAction" />
                <output>
                    <soap:body use="encoded" namespace="urn:DemoService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </output>
            </operation>
        </binding>
        <service name="DemoServiceEndpoint">
            <port name="DemoServicePort" binding="typens:DemoServiceBinding">
                <soap:address location="http://localhost/demo.php" />
            </port>
        </service>
    </definitions>
    demo.php
    Code:
    <?php
       
       function ReturnArrayOfObject()
       {
         return array(array('ObjectID' => 1, 'ObjectName' => 'asdf'), array('ObjectID' => 2, 'ObjectName' => 'asdf'));
       }
       
       $opts = Array();
       $opts['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP;
       $opts['cache_wsdl']  = WSDL_CACHE_NONE;
       
       $server = new SoapServer('demo.wsdl', $opts);
       $server->addFunction('ReturnArrayOfObject');
       $server->handle();
       
    ?>
    test.php
    Code:
    <?php
       $client = new SoapClient('http://localhost/demo.wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
       $res    = $client -> ReturnArrayOfObject();
       var_dump($res);
    
    ?>

  5. #5

    Default Re: Need Help: Array in WSDL

    ako suggestion kung ok na gani kay i-enable balik ang cache kay resource hog na kung i-read niya all the time. here's your original code working fine with the cache enabled... http://home.banogon.com/soap/

    ang default soap wsdl cache time to live kay 86400 seconds (24 hours), that's why after 1 day ni-ok na. i-check sa phpinfo()

  6. #6

    Default Re: Need Help: Array in WSDL

    Yes, pero while ga develop ko needed nako i-off since dili man mu-effect dayon ang akong mga changes. took me hours to notice nga mao ra diay to probs nako. T_T thank you so much for the help.

  7. #7

    Default Re: Need Help: Array in WSDL

    akong technique ana bro kay i-disable locally sa php.ini ang soap cache then set to 0 ang ttl sa wsdl cache. para di na kinghanlan i-disable through php code ang cache. so wa na kinghanlan usbon sa code inig upload sa production server.

    tip ra

  8. #8

    Default Re: Need Help: Array in WSDL

    Will do. Thanks. On a side note, sakto ba akong wsdl para sa array? mura dili man. ganahan unta ko nga ang i-return nga result kay array of objects.

  9.    Advertisement

Similar Threads

 
  1. NEED HELP: Investing in Mutual Funds and Stocks
    By likyam in forum Business, Finance & Economics Discussions
    Replies: 13
    Last Post: 01-10-2013, 08:11 AM
  2. NEED HELP: International Culinary School in Banawa
    By denis_jay in forum Food & Beverages
    Replies: 48
    Last Post: 11-09-2012, 09:44 PM
  3. Guys need help hdd in raid 0..
    By acre020 in forum Computer Hardware
    Replies: 2
    Last Post: 03-05-2011, 01:34 PM
  4. need help in going to Aparri.
    By mnpesiao in forum Destinations
    Replies: 4
    Last Post: 05-21-2006, 11:16 AM
  5. Want to buy a new mp3 player. Need help in selecting one.
    By metdumangas in forum Gizmos & Gadgets (Old)
    Replies: 21
    Last Post: 01-04-2006, 09:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top