4 Replies - 2568 Views - Last Post: 18 March 2013 - 03:17 PM Rate Topic: -----

#1 baxter111  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 77
  • Joined: 30-June 08

XML to Array - SoapClient

Posted 15 March 2013 - 03:39 AM

Hi Guys,

Can you help me out or point me in the right direction, I'm trying to perform a soap request to a WSDL feed but I'm not getting anything back.

When I use standard XML everything seems to work OK - how would I write the following into an array:

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body> 
    <SupplierDirectorySearch xmlns="SOAPREQUEST"> 
      <SupplierSearchDetails ClassVersion="1.0"> 
        <Identification> 
          <SchemeOperatorRef>59582</SchemeOperatorRef> 
          <SecurityToken>MYTOKEN</SecurityToken>
        </Identification>
        <ApprovedServices ServiceRepair="Y" MOT="" Tyres="" CollectionDelivery="" CourtesyCar="" WhileUWait="" Callout24Hour="" BreakdownCover="" CollectionDeliveryNotes="" CourtesyCarNotes="" Inspections=""/>
        <SupplierLocation>BB1</SupplierLocation> 
        <SearchRadiusMiles>300</SearchRadiusMiles> 
        <Preference>P</Preference> 
        <MaxReturnNumber>5</MaxReturnNumber> 
        <PageNo>0</PageNo> 
      </SupplierSearchDetails> 
    </SupplierDirectorySearch> 
  </soap:Body> 
</soap:Envelope>';



I've written the following so far but it just doesn't seem to like it:

$client = new SoapClient("URL?WSDL", $option);
$res = $client->SupplierDirectorySearch(
    array('SupplierSearchDetails'=> 
      array('Identification' => array('SchemeOperatorRef'=>'61', 'SecurityToken'=>'MYTOKEN'),
        'ApprovedServices' => array(
        'ServiceRepair'=>'Y',
        'MOT'=>'',
        'Tyres'=>'',
        'CollectionDelivery'=>'',
        'CourtesyCar'=>'',
        'WhileUWait'=>'',
        'Callout24Hour'=>'',
        'BreakdownCover'=>'',
        'CollectionDeliveryNotes'=>'',
        'CourtesyCarNotes'=>'',
        'Inspections'=>'',
          ),  
        'SupplierLocation' => 'BB1',
        'SearchRadiusMiles' => '2',
        'Preference' => 'P',
        'MaxReturnNumber' => '5',
        'PageNo' => '0'
      )
      )
    );




Can anyone help me out.

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: XML to Array - SoapClient

#2 baxter111  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 77
  • Joined: 30-June 08

Re: XML to Array - SoapClient

Posted 15 March 2013 - 03:51 AM

To add, this is what is getting passed by the SOAPClient

REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="OneLink_ServiceBookingComponent"><SOAP-ENV:Body><ns1:SupplierDirectorySearch><ns1:SupplierSearchDetails><ns1:Identification><ns1:SchemeOperatorRef>61</ns1:SchemeOperatorRef><ns1:SecurityToken>MYTOKEN</ns1:SecurityToken></ns1:Identification><ns1:SupplierLocation>BB1</ns1:SupplierLocation><ns1:SearchRadiusMiles>2</ns1:SearchRadiusMiles><ns1:Preference>P</ns1:Preference><ns1:ApprovedServices ServiceRepair="Y" MOT="" Tyres="" CollectionDelivery="" CourtesyCar="" WhileUWait="" Callout24Hour="" BreakdownCover="" CollectionDeliveryNotes="" CourtesyCarNotes="" Inspections=""/><ns1:MaxReturnNumber>5</ns1:MaxReturnNumber><ns1:PageNo>0</ns1:PageNo></ns1:SupplierSearchDetails></ns1:SupplierDirectorySearch></SOAP-ENV:Body></SOAP-ENV:Envelope>


Was This Post Helpful? 0
  • +
  • -

#3 baxter111  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 77
  • Joined: 30-June 08

Re: XML to Array - SoapClient

Posted 15 March 2013 - 05:30 AM

Just looking at this a little further - do I need to add attributes to the XML request like this:

try using this 
<?php 
 $amount['_'] = 25; 
 $amount['currencyId'] = 'GBP'; 
 $encodded = new SoapVar($amount, SOAP_ENC_OBJECT); 

?> 
and end result wound be 
<amount currencyId="GBP">25</amount> 



Was This Post Helpful? 0
  • +
  • -

#4 CynicalSolution  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 15
  • Joined: 17-March 13

Re: XML to Array - SoapClient

Posted 17 March 2013 - 06:23 AM

Any reason you cant use SimpleXML, it can handle anything XML and is fairly simple.
Was This Post Helpful? 0
  • +
  • -

#5 baxter111  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 77
  • Joined: 30-June 08

Re: XML to Array - SoapClient

Posted 18 March 2013 - 03:17 PM

Can anyone shed any light on this?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1