[PHP] Need Help bei Soap/WSDL

Dieses Thema im Forum "Webentwicklung" wurde erstellt von LordSash, 5. Juni 2009 .

Schlagworte:
  1. 5. Juni 2009
    Need Help bei Soap/WSDL

    Moin Moin zusammen

    Ich hab mir mal gedacht, ich mach mich an Soap und WSDL ran...nur blick ich im moment nich mehr wirklich durch....

    Also, ich hab 3 Services geschrieben die verwendet werden können.

    hier der Code dazu:

    PHP:
    $soap  = new  SoapServer ( "wsdlFile.wsdl" );
    $soap -> addFunction ( 'getProviderList' );
    $soap -> addFunction ( 'getContactListOfUser' );
    $soap -> addFunction ( 'sendMessageToSelectedContactsOfUser' );
    $soap -> handle ();
        
    function 
    getProviderList ()
    {
        

    }

    function 
    getContactListOfUser ( $login $password $network
    {
        

    }

    function 
    sendMessageToSelectedContactsOfUser ( $login $password $network $messageBody $messageTitle $contactList
    {
        

    }

    Der Client sieht wie folgt aus - nur zum testen....

    PHP:
    $client  = new  SoapClient ( "wsdlFile.wsdl" );
    var_dump ( $client -> __getFunctions ());
    var_dump ( $client -> getProviderList ());
    Und zu guter letzt die wsdl Datei....

    PHP:
    <? xml version = "1.0" ?>
    <definitions name="MyContacterService"
        targetNamespace="urn:MyContacterService" xmlns:tns="urn:MyContacterService"
        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:complexType name="ServiceResponse">
                <xsd:all>
                    <xsd:element name="aData" type="anySimpleType" />
                </xsd:all>
            </xsd:complexType>

            <xsd:complexType name="ServiceRequestsContainer">
                <xsd:all>
                    <xsd:element name="aRequests" type="anySimpleType" />
                </xsd:all>
            </xsd:complexType>

            <xsd:complexType name="ServiceResponsesContainer">
                <xsd:all>
                    <xsd:element name="aResponses" type="anySimpleType" />
                </xsd:all>
            </xsd:complexType>            

            <xsd:complexType name="ServiceResponse">
                <xsd:sequence>
                    <xsd:element name="NewElement" type="xsd:string"></xsd:element>
                </xsd:sequence>
            </xsd:complexType>
            
            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:MyContacterService">
                <xsd:complexType name="stringArray">
                    <xsd:sequence>
                        <xsd:element name="stringArray" type="xsd:string[]"></xsd:element>
                    </xsd:sequence>
                </xsd:complexType></xsd:schema>
        </types>
        
        <message name="getProviderListRequest">
        </message>
        <message name="getProviderListResponse">
            <part name="return" type="tns:stringArray" />
        </message>

        <wsdl:message name="getContactListOfUserRequest">
            <wsdl:part name="login" type="xsd:string"></wsdl:part>
            <wsdl:part name="password" type="xsd:string"></wsdl:part>
            <wsdl:part name="network" type="xsd:string"></wsdl:part>
        </wsdl:message>
        <wsdl:message name="getContactListOfUserResponse">
            <part name="return" type="tns:stringArray" />
        </wsdl:message>
        
        <wsdl:message name="sendMessageToSelectedContactsOfUserRequest">
            <wsdl:part name="login" type="xsd:string"></wsdl:part>
            <wsdl:part name="password" type="xsd:string"></wsdl:part>
            <wsdl:part name="network" type="xsd:string"></wsdl:part>
            <wsdl:part name="messageBody" type="xsd:string"></wsdl:part>
            <wsdl:part name="messageTitle" type="xsd:string"></wsdl:part>
            <wsdl:part name="contactList" type="tns:stringArray"></wsdl:part>
        </wsdl:message>
        <wsdl:message name="sendMessageToSelectedContactsOfUserResponse">
            <part name="return" type="xsd:string" />
        </wsdl:message>
        
        <wsdl:message name="getContactListOfUser_faultMsg">
            <wsdl:part name="fault" type="xsd:string"></wsdl:part>
        </wsdl:message>
        <wsdl:message name="getContactListOfUser_faultMsg1">
            <wsdl:part name="fault" type="xsd:string"></wsdl:part>
        </wsdl:message>
        
        <portType name="MyContacterServicePort">
            <operation name="getProviderList">
                <output message="tns:getProviderListResponse" />
            </operation>
            <wsdl:operation name="getContactListOfUser">
                <wsdl:input message="tns:getContactListOfUserRequest"></wsdl:input>
                <wsdl:output message="tns:getContactListOfUserResponse"></wsdl:output>
            </wsdl:operation>
            <wsdl:operation name="sendMessageToSelectedContactsOfUser">
                <wsdl:input message="tns:sendMessageToSelectedContactsOfUserRequest"></wsdl:input>
                <wsdl:output message="tns:sendMessageToSelectedContactsOfUserResponse"></wsdl:output>
            </wsdl:operation>
        </portType>

        <binding name="MyContacterServiceBinding"
            type="tns:MyContacterServicePort">
            <soap:binding style="rpc"
                transport="http://schemas.xmlsoap.org/soap/http" />
            <operation name="getProviderList">
                <soap:operation soapAction="urn:MyContacterServiceAction" />
                <input>
                    <soap:body use="encoded"
                        namespace="urn:MyContacterService"
                        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </input>
                <output>
                    <soap:body use="encoded"
                        namespace="urn:MyContacterService"
                        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </output>
            </operation>
            <operation name="getContactListOfUser">
                <soap:operation soapAction="urn:MyContacterServiceAction" />
                <input>
                    <soap:body use="encoded"
                        namespace="urn:MyContacterService"
                        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </input>
                <output>
                    <soap:body use="encoded"
                        namespace="urn:MyContacterService"
                        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </output>
            </operation>
            <operation name="sendMessageToSelectedContactsOfUser">
                <soap:operation soapAction="urn:MyContacterServiceAction" />
                <input>
                    <soap:body use="encoded"
                        namespace="urn:MyContacterService"
                        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </input>
                <output>
                    <soap:body use="encoded"
                        namespace="urn:MyContacterService"
                        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
                </output>
            </operation>
        </binding>

        <service name="MyContacterServiceService">
            <port name="MyContacterServicePort"
                binding="tns:MyContacterServiceBinding">
                <soap:address location="http://localhost/soapServices.php" />
            </port>
        </service>
      
    </definitions>
    (xml blöcke scheints leider in dem board nich zu geben :-/)

    Noch kurz zur erleuterung, es werden nur Strings oder string Array als Parameter bzw Rückgabe Wert übergeben!

    die Methode __getFunctions(); zeigt mir auch die richtigen methoden mit Parametern an, nur wenn ich diese Aufrufen will bekomm ich einen Timeout oder die Meldung das der host nicht zu erreichen ist....

    Wär cool wenn mir irgendjemand weiter helfen könne
     
  2. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.