PHP SOAP с несколькими сервисами в wsdl

Rustam1234

Новичок
Добрый день!

Как на PHP реализовать несколько сервисов которые описаны в одном wsdl файле? (С одним сервисом все нормально работает)
Пример wsdl :
HTML:
<?xml version="1.0"?>
<definitions name="MyDefinition" targetNamespace="urn:myTargetNamespace"
        xmlns:tns="urn:myTns"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns="http://schemas.xmlsoap.org/wsdl/">

    <message name="myRequest">
        <part name="reqParam" type="xsd:string"/>
    </message>
    <message name="myResponse">
        <part name="resParam" type="xsd:string"/>
    </message>

    <portType name="MyPortType">
        <operation name="hello">
            <input message="tns:myRequest"/>
            <output message="tns:myResponse"/>
        </operation>
    </portType>
    <portType name="MyPortType2">
        <operation name="hello2">
            <input message="tns:myRequest"/>
            <output message="tns:myResponse"/>
        </operation>
    </portType>

    <binding name="MyBinding" type="tns:MyPortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="hello">
            <soap:operation soapAction=""/>
            <input>
                <soap:body use="encoded" namespace="urn:myInputNamespace"
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body use="encoded" namespace="urn:myOutputNamespace"
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
    </binding>
    <binding name="MyBinding2" type="tns:MyPortType2">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="hello2">
            <soap:operation soapAction=""/>
            <input>
                <soap:body use="encoded" namespace="urn:myInputNamespace"
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </input>
            <output>
                <soap:body use="encoded" namespace="urn:myOutputNamespace"
                    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </output>
        </operation>
    </binding>

    <service name="MyService">
        <port name="MyPort" binding="tns:MyBinding">
            <soap:address location="http://localhost/example/HelloServerWsdl.php"/>
        </port>
    </service>
    <service name="MyService2">
        <port name="MyPort2" binding="tns:MyBinding2">
            <soap:address location="http://localhost/example/HelloServerWsdl.php"/>
        </port>
    </service>
</definitions>
Вариант с несколькими портами не подходит(есть готовые клиенты к подобному конфигу)
 

WMix

герр M:)ller
Партнер клуба
странно конечно, что с вопросом по написанию WSDL, обращаешься на PHP форум. местные обитатели вероятнее всего не пишут эту гадость, а генерят.
вероятнее всего это пишется приблизительно так!
PHP:
...
<message name="myRequestHello">
    <part name="reqParam" type="xsd:string"/>
</message>

<message name="myResponseHello">
    <part name="resParam" type="xsd:string"/>
</message>

<message name="myRequestHello2">
    <part name="reqParam" type="xsd:string"/>
</message>

<message name="myResponseHello2">
    <part name="resParam" type="xsd:string"/>
</message>

<portType name="MyPortType">
    <operation name="hello">
        <input message="tns:myRequestHello"/>
        <output message="tns:myResponseHello"/>
    </operation>
    <operation name="hello2">
        <input message="tns:myRequestHello2"/>
        <output message="tns:myResponseHello2"/>
    </operation>
</portType>

<binding name="MyBinding" type="tns:MyPortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="hello">...</operation>
    <operation name="hello2">...</operation>
</binding>

<service name="MyService">
    <port name="MyPort" binding="tns:MyBinding">
        <soap:address location="http://localhost/example/HelloServerWsdl.php"/>
    </port>
</service>
...
 

Rustam1234

Новичок
Я немного не правильно выразился, с одним сервисом в wsdl файле все работает нормально, как вы написали будет нормально работать.
У меня сгенерированный wsdl по виду как я привел, те по одной функции в сервисе и всего 2 сервиса. Собственно вопрос в том, как такой конфиг грузить в php скрипте и объявлять эти функции? Долгие поиски привели только к мысли реализовать cgi на C++ с использованием gSOAP, все же хотелось бы на PHP
 

WMix

герр M:)ller
Партнер клуба
я пользую zend.
PHP:
$client = new Zend_Soap_Client("MyService.wsdl");
$result1 = $client->method1(10);
 
Сверху