@html_profi

Как передать SOAP сервису сложный тип?

Всем привет!

Настраиваю взаимодействие со сторонним сервисом и никак не могу правильно передать параметры в него. Сервис выдает ошибки о некорректности параметра.

Вот кусок WSDL документа
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12bind="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.test.ru/xdto_UH_BP" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsd1="http://www.test.ru/xdto_UH_BP" xmlns:xsd2="http://www.test.ru/xdto_NSI" name="test_name_OS" targetNamespace="http://www.test.ru/xdto_UH_BP">

    <types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xs1="http://www.test.ru/xdto_NSI" xmlns:xs2="http://www.test.ru/xdto_UH_BP" targetNamespace="http://www.test.ru/xdto_UH_BP" attributeFormDefault="unqualified" elementFormDefault="qualified">
            <xs:complexType name="Parameters">
                <xs:choice>
                    <xs:element name="TypeRequest" type="tns:TypeRequest"/>
                    <xs:element name="TypeSelect">
                        <xs:simpleType>
                            <xs:restriction base="xs:string">
                                <xs:enumeration value="Changed"/>
                                <xs:enumeration value="Period"/>
                            </xs:restriction>
                        </xs:simpleType>
                    </xs:element>
                    <xs:element name="PeriodStart" type="xs:dateTime" nillable="true" minOccurs="0"/>
                    <xs:element name="OnlyGUID" type="xs:boolean" nillable="true" minOccurs="0"/>
                    <xs:element name="ExecutionDate" type="xs:date" nillable="true" minOccurs="0"/>
                </xs:choice>
            </xs:complexType>
            <xs:simpleType name="TypeRequest">
                <xs:restriction base="xs:string">
                    <xs:enumeration value="DocumentRequest"/>
                    <xs:enumeration value="ActionRequest"/>
                </xs:restriction>
            </xs:simpleType>
            <xs:element name="GetInfo">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="Parameters" type="tns:Parameters"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </types>

    <message name="GetInfoRequestMessage">
        <part name="parameters" element="tns:GetInfo"/>
    </message>

    <portType name="test_name_OSPortType">
        <operation name="GetInfo">
            <input message="tns:GetInfoRequestMessage"/>
        </operation>
    </portType>

    <binding name="test_name_OSSoap12Binding" type="tns:test_name_OSPortType">
        <operation name="GetInfo">
            <soap12bind:operation style="document" soapAction="http://www.test.ru/xdto_UH_BP#test_name_OS:GetInfo"/>
            <input>
                <soap12bind:body use="literal"/>
            </input>
        </operation>
    </binding>

    <service name="test_name__OS">
        <port name="test_name__OSSoap12" binding="tns:test_name__OSSoap12Binding">
            <soap12bind:address location="http://location.ru"/>
        </port>
    </service>

</definitions>

и php код на выполнение метода

try {
    $client = new SoapClient("http://service.wsdl", [
            'login' => $login,
            'password' => $password,
            'soap_version' => SOAP_1_2,
            'cache_wsdl' => WSDL_CACHE_NONE,
            'trace' => true,
            'features' => SOAP_USE_XSI_ARRAY_TYPE,
            'use'      => SOAP_LITERAL
        ]);
    $param = [
        "Parameters" => [
            "TypeRequest" => "DocumentRequest",
            "TypeSelect" => "Changed",
            "ExecutionDate" => "2019-12-15",
        ]
    ];
    $result = $client->GetData($param);

} catch (Exception $e) {
    echo $e->getMessage();
}


Ругается на некорректность параметра "TypeSelect". Я так понимаю, что я его неправильно передаю.
Как вообще передавать сложные типы SOAP сервису?

Заранее всем благодарен за помощь!!!
  • Вопрос задан
  • 362 просмотра
Пригласить эксперта
Ответы на вопрос 1
@olezh
Пробовал:
$param = [
        "Parameters" => [
            "TypeRequest" => "DocumentRequest",
            "TypeSelect" =>[ 
                "Changed"
             ],
            "ExecutionDate" => "2019-12-15",
        ]
    ];
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы