Answer the question
In order to leave comments, you need to log in
How to pass complex type to SOAP service?
Hello!
I'm setting up interaction with a third-party service and I can't correctly pass parameters to it. The service gives errors about incorrect parameter.
Here is a piece of the WSDL document
<?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>
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();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question