S
S
Sebastian Pereira2014-04-15 13:47:50
PHP
Sebastian Pereira, 2014-04-15 13:47:50

SOAP, PHP, how to make a request?

Hello. Didn't work with SOAP. I read the theory, roughly understood what was happening. Help make a request.
wsdl:

<xsd:element name="ZfmCrmLoyMshInf">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="IsCrd" type="tns:ZstCrdCrmLoyMshInfIn" minOccurs="0"/>
<xsd:element name="IsStore" type="tns:ZstStore" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ZfmCrmLoyMshInfResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EsCrd" type="tns:ZstCrdCrmLoyMshInfOut"/>
<xsd:element name="EsDynAttr" type="tns:ZstDynAttr"/>
<xsd:element name="EsLp" type="tns:ZstLp"/>
<xsd:element name="EsMemb" type="tns:ZstMemb"/>
<xsd:element name="EsMsh" type="tns:ZstMshCrmLoyMshInfOut"/>
<xsd:element name="EtCampList" type="tns:ZttChar24"/>
<xsd:element name="EtErrorList" type="tns:ZttErrorList"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

Tell me "from the very beginning", how to make a request for wsdl and then get an answer?
PS I create a connection, it works.
UPD*!
Thank you very much! The code works, but I don't get an answer, because of my stupidity, apparently. Found the function I needed.
Tell me how to understand what parameters it accepts in order to pass them to it?
UPD*2
<xsd:element name="ZfmCrmLoyMshInf">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="IsCrd" type="tns:ZstCrdCrmLoyMshInfIn" minOccurs="0"/>
<xsd:element name="IsStore" type="tns:ZstStore" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ZfmCrmLoyMshInfResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="EsCrd" type="tns:ZstCrdCrmLoyMshInfOut"/>
<xsd:element name="EsDynAttr" type="tns:ZstDynAttr"/>
<xsd:element name="EsLp" type="tns:ZstLp"/>
<xsd:element name="EsMemb" type="tns:ZstMemb"/>
<xsd:element name="EsMsh" type="tns:ZstMshCrmLoyMshInfOut"/>
<xsd:element name="EtCampList" type="tns:ZttChar24"/>
<xsd:element name="EtErrorList" type="tns:ZttErrorList"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>


<wsdl:operation name="ZfmCrmLoyMshInf">
<wsdl:input message="tns:ZfmCrmLoyMshInf"/>
<wsdl:output message="tns:ZfmCrmLoyMshInfResponse"/>
</wsdl:operation>



<wsdl:message name="ZfmCrmLoyMshInf">
<wsdl:part name="parameters" element="tns:ZfmCrmLoyMshInf"/>
</wsdl:message>
<wsdl:message name="ZfmCrmLoyMshInfResponse">
<wsdl:part name="parameter" element="tns:ZfmCrmLoyMshInfResponse"/>
</wsdl:message>

UPD*3
Here is a SOAPUI request that works:
I.e. i send 1120000000001530, 0003
<soapenv:Body>
      <urn:ZfmCrmLoyMshInf>
         <!--Optional:-->
         <IsCrd>
            <ExtId>1120000000001530</ExtId>
         </IsCrd>
         <!--Optional:-->
         <IsStore>
            <Id>0003</Id>
         </IsStore>
      </urn:ZfmCrmLoyMshInf>
   </soapenv:Body>
</soapenv:Envelope>

Returns me:
<soap-env:Header/>
   <soap-env:Body>
      <n0:ZfmCrmLoyMshInfResponse xmlns:n0="urn:sap-com:soap:functions:mc-style">
         <EsCrd>
            <ExtId>1120000000001530</ExtId>
            <Status>Активно</Status>
            <Estat>E0003</Estat>
            <CardValidFrom>2013-11-07</CardValidFrom>
            <CardValidTo>9999-12-31</CardValidTo>
         </EsCrd>
         <EsDynAttr>
            <Zsumofpurch>0</Zsumofpurch>
         </EsDynAttr>
         <EsLp>
            <Id>Zaratustra</Id>
            <Name>Программа</Name>
            <LoyType>B</LoyType>
         </EsLp>
         <EsMemb>
            <Id>3000023950</Id>
            <Birthdt>2013-02-29</Birthdt>
         </EsMemb>
         <EsMsh>
            <Guid>ACFanIPNHtOR9rGVA2en1Q==</Guid>
            <Status>Активно</Status>
            <Estat>E0002</Estat>
            <Tier>Базовый</Tier>
            <Etier>GBT0_BASE</Etier>
            <Balance>4000.0</Balance>
            <EmemsType>STDMEM</EmemsType>
            <MemsType>Участие в программе</MemsType>
         </EsMsh>
         <EtCampList/>
         <EtErrorList>
            <item>
               <RType>S</RType>
               <RId>ZCRM_LOY_MSH_INF</RId>
               <RNum>000</RNum>
               <RMessage>Информация успешно получена</RMessage>
            </item>
         </EtErrorList>
      </n0:ZfmCrmLoyMshInfResponse>
   </soap-env:Body>
</soap-env:Envelope>

In php it looks like this:
...
$request = $client->ZfmCrmLoyMshInf(1120000000001530, 0002);
echo $request->ZfmCrmLoyMshInfResponse->EsCrd;
...

I get:
Fatal error: Uncaught SoapFault exception
Am I passing parameters incorrectly?! Tell me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Denisov, 2014-04-15
@uJlJluduAH

ini_set('soap.wsdl_cache_enabled', '0'); 
ini_set('soap.wsdl_cache_ttl', '0'); 
try {
$client = new SoapClient("адрес wsdl", array('trace' => true));
$params = array(массив параметров);
        
$request = $client->Register($params); // делаем запрос, здесь Register это название функции в wsdl сервисе
$itog = $request->Result; // получаем запрос и присваиваем его переменной itog. Result это название поля которое отдаст wsdl
}
catch (SoapFault $exception) 
{
echo $exception->getMessage(); // ошибка если не ок
}

Something like this) under your wsdl, just write everything
To find out the available functions, their names, run
And this
will return the field types in the service

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question