consume webservice wsdl with php

Asked

Viewed 6,999 times

1

Hello, I’m having a question, I don’t know where to start to consume the webservice, I have implemented other simpler webservices, but this I have doubts about the fields that are list: ,

        <iked:Categories>
           <!--Zero or more repetitions:-->
           <iked:clsFilterCategory>
              <iked:CategoryCode>0</iked:CategoryCode>
              <!--Optional:-->
              <iked:CategoryInternalCode>18</iked:CategoryInternalCode>
              <iked:StoreCode>0</iked:StoreCode>
           </iked:clsFilterCategory>
        </iked:Categories>
<iked:Options>
               <!--Zero or more repetitions:-->
               <iked:clsFilterOption>
                  <iked:Id>0</iked:Id>
                  <!--Optional:-->
                  <iked:InternalCode>1</iked:InternalCode>
                  <!--Optional:-->
                  <iked:Name>Motor</iked:Name>
                  <iked:OrderDisplay>1</iked:OrderDisplay>
                  <iked:StoreCode>0</iked:StoreCode>
                  <!--Optional:-->
                  <iked:OptionsProducts>
                     <!--Zero or more repetitions:-->
                     <iked:clsFilterOptionProduct>
                        <iked:ProductCode>0</iked:ProductCode>
                        <!--Optional:-->
                        <iked:ProductInternalCode>08523</iked:ProductInternalCode>
                        <!--Optional:-->
                        <iked:Value>?</iked:Value>
                        <iked:StoreCode>0</iked:StoreCode>
                     </iked:clsFilterOptionProduct>
                  </iked:OptionsProducts>
               </iked:clsFilterOption>
            </iked:Options>

follows my php code:

$client = new SoapClient('http://motorpecas.vertical.rakuten.com.br/ikcwebservice/filterautoparts.asmx?wsdl');      
            $function = 'InsertFilter';
            //para listar todos fabricantes, deixar em branco  CodigoInternoFabricante
            $arguments= array('InsertFilter' => array(
                                    'Id'                => 0,
                                    'Name'              => 'FiltroMotor',
                                    'Title'             => 'Filtro Categoria Motor',
                                    'InternalCode'      => '1010',
                                    'Status'            => '1',
                                    'Main'              => 0,
//aqui onde tenho dúvida
                                        'CategoryCode'  => 0,
                                        'CategoryInternalCode'=> 18,
                                        'StoreCode'     => 0,
  //aqui onde tenho dúvida
                                        'Id'            => 0,
                                        'InternalCode'  => 1,
                                        'Name'          => 'Motor',
                                        'OrderDisplay'  => 1,
                                        'StoreCode'     => 0,
                                        'ProductCode'=> 0,
                                        'ProductInternalCode' =>08523,
                                        'Value' => 0, 
                                        'StoreCode'         => '0',

                                    'StoreCode'         => '0'


                            ));

            $options = array('location' => 'http://motorpecas.vertical.rakuten.com.br/ikcwebservice/filterautoparts.asmx');

            $result = $client->__soapCall($function, $arguments, $options);

            //echo 'Response: ';
            print_r($result);

Wsdl is locked to access only from my fixed ip, so I put in Pastebin http://motorpecas.vertical.rakuten.com.br/ikcwebservice/filterautoparts.asmx?wsdl Wsld => http://pastebin.com/kihce6i7

I used the program: Soapui 5.0 - I was able to register normally,

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:iked="http://www.ikeda.com.br">
   <soapenv:Header>
      <iked:clsSoapHeader>
         <!--Optional:-->
         <iked:A1>?</iked:A1>
         <!--Optional:-->
         <iked:A2>?</iked:A2>
      </iked:clsSoapHeader>
   </soapenv:Header>
   <soapenv:Body>
      <iked:InsertFilter>
         <!--Optional:-->
         <iked:Filter>
            <iked:Id>0</iked:Id>
            <!--Optional:-->
            <iked:Name>FiltroMotor</iked:Name>
            <!--Optional:-->
            <iked:Title>Filtro Categoria Motor</iked:Title>
            <!--Optional:-->
            <iked:InternalCode>1010</iked:InternalCode>
            <iked:Status>1</iked:Status>
            <iked:Main>0</iked:Main>
            <!--Optional:-->
            <iked:Categories>
               <!--Zero or more repetitions:-->
               <iked:clsFilterCategory>
                  <iked:CategoryCode>0</iked:CategoryCode>
                  <!--Optional:-->
                  <iked:CategoryInternalCode>18</iked:CategoryInternalCode>
                  <iked:StoreCode>0</iked:StoreCode>
               </iked:clsFilterCategory>
            </iked:Categories>
            <!--Optional:-->
            <iked:Options>
               <!--Zero or more repetitions:-->
               <iked:clsFilterOption>
                  <iked:Id>0</iked:Id>
                  <!--Optional:-->
                  <iked:InternalCode>1</iked:InternalCode>
                  <!--Optional:-->
                  <iked:Name>Motor</iked:Name>
                  <iked:OrderDisplay>1</iked:OrderDisplay>
                  <iked:StoreCode>0</iked:StoreCode>
                  <!--Optional:-->
                  <iked:OptionsProducts>
                     <!--Zero or more repetitions:-->
                     <iked:clsFilterOptionProduct>
                        <iked:ProductCode>0</iked:ProductCode>
                        <!--Optional:-->
                        <iked:ProductInternalCode>08523</iked:ProductInternalCode>
                        <!--Optional:-->
                        <iked:Value>?</iked:Value>
                        <iked:StoreCode>0</iked:StoreCode>
                     </iked:clsFilterOptionProduct>
                  </iked:OptionsProducts>
               </iked:clsFilterOption>
            </iked:Options>
            <iked:StoreCode>0</iked:StoreCode>
         </iked:Filter>
      </iked:InsertFilter>
   </soapenv:Body>
</soapenv:Envelope>



    POST /ikcwebservice/filterautoparts.asmx HTTP/1.1
Host: motorpecas.vertical.rakuten.com.br
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.ikeda.com.br/InsertFilter"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <clsSoapHeader xmlns="http://www.ikeda.com.br">
      <A1>string</A1>
      <A2>string</A2>
    </clsSoapHeader>
  </soap:Header>
  <soap:Body>
    <InsertFilter xmlns="http://www.ikeda.com.br">
      <Filter>
        <Id>int</Id>
        <Name>string</Name>
        <Title>string</Title>
        <InternalCode>string</InternalCode>
        <Status>boolean</Status>
        <Main>boolean</Main>
        <Categories>
          <clsFilterCategory>
            <CategoryCode>int</CategoryCode>
            <CategoryInternalCode>string</CategoryInternalCode>
            <StoreCode>int</StoreCode>
          </clsFilterCategory>
          <clsFilterCategory>
            <CategoryCode>int</CategoryCode>
            <CategoryInternalCode>string</CategoryInternalCode>
            <StoreCode>int</StoreCode>
          </clsFilterCategory>
        </Categories>
        <Options>
          <clsFilterOption>
            <Id>int</Id>
            <InternalCode>string</InternalCode>
            <Name>string</Name>
            <OrderDisplay>int</OrderDisplay>
            <StoreCode>int</StoreCode>
            <OptionsProducts xsi:nil="true" />
          </clsFilterOption>
          <clsFilterOption>
            <Id>int</Id>
            <InternalCode>string</InternalCode>
            <Name>string</Name>
            <OrderDisplay>int</OrderDisplay>
            <StoreCode>int</StoreCode>
            <OptionsProducts xsi:nil="true" />
          </clsFilterOption>
        </Options>
        <StoreCode>int</StoreCode>
      </Filter>
    </InsertFilter>
  </soap:Body>
</soap:Envelope>

1 answer

1


Fixed php code, missing the hierarchy (array inside array)

$client = new SoapClient('http://motorpecas.vertical.rakuten.com.br/ikcwebservice/filterautoparts.asmx?wsdl');      
            $function = 'InsertFilter';
            //para listar todos fabricantes, deixar em branco  CodigoInternoFabricante
            $arguments= array('InsertFilter' => array(
                                'Filter'=> array(
                                    'Id'                => 0,
                                    'Name'              => 'FiltroMotor',
                                    'Title'             => 'Filtro Categoria Motor',
                                    'InternalCode'      => '1010',
                                    'Status'            => '1',
                                    'Main'              => 0,


                                    'Categories'        => array(
                                            'clsFilterCategory'=> array(
                                                'CategoryCode'          => 0,
                                                'CategoryInternalCode'  => '18',
                                                'StoreCode'             => 0
                                            )
                                        ),

                                    'Options'           => array(
                                            'clsFilterOption'   => array(
                                                'Id'                    => 0,
                                                'InternalCode'          => '1',
                                                'Name'                  => 'Motor',
                                                'OrderDisplay'          => 1,
                                                'StoreCode'             => 0,


                                                'OptionsProducts'  => array(
                                                    'clsFilterOptionProduct'    => array(
                                                        'ProductCode'           => 0,
                                                        'ProductInternalCode'   => '08523',
                                                        'Value'                 => '0', 
                                                        'StoreCode'             => '0'
                                                    )//fecha clsFilterOptionProduct
                                                )//fecha OptionsProducts
                                            )//fecha clsFilterOption
                                        ),//fecha options
                                'StoreCode'         => 0                
                            )));
    print_r($arguments);

            $options = array('location' => 'http://motorpecas.vertical.rakuten.com.br/ikcwebservice/filterautoparts.asmx');

            $result = $client->__soapCall($function, $arguments, $options);


            //echo 'Response: ';
            print_r($result);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.