2010-10-28 5 views
1

J'ai une classe d'énumération et je veux définir une valeur à partir de ceci dans une fonction. Mais je ne suis pas abel pour le faire. Il choisit toujours le poing en ligne, elle est le client.Nusoap simpletype énumération

$server->wsdl->addSimpleType(
    'AddressType', 
    'xsd:string', 
    'SimpleType', 
    'struct', 
    array(
     'Customer', 
     'Order', 
     'Delivery', 
     'Invoice', 
     'Contact' 
) 
); 



Included in this struct with name Type: 



// ---- AddressData ---------------------------------------------------------------- 

$server->wsdl->addComplexType(
    'AddressData', 
    'complexType', 
    'struct', 
    'all', 
    '', 
array(
     'Number' => array('name'=>'Number','type'=>'xsd:string'), 
     'Name1' => array('name'=>'Name1','type'=>'xsd:string'), 
     'Name2' => array('name'=>'Name2','type'=>'xsd:string'), 
     'StreetAddress1' => array('name'=>'StreetAddress1','type'=>'xsd:string'), 
     'StreetAddress2' => array('name'=>'StreetAddress2','type'=>'xsd:string'), 
     'StreetAddress3' => array('name'=>'StreetAddress3','type'=>'xsd:string'), 
     'Postcode' => array('name'=>'Postcode','type'=>'xsd:string'), 
     'City' => array('name'=>'City','type'=>'xsd:string'), 
     'Mobile' => array('name'=>'Mobile','type'=>'xsd:string'), 
     'Phone' => array('name'=>'Phone','type'=>'xsd:string'), 
     'Email' => array('name'=>'Email','type'=>'xsd:string'), 
     'Fax' => array('name'=>'Fax','type'=>'xsd:string'), 
     'PostOfficeBox' => array('name'=>'PostOfficeBox','type'=>'xsd:string'), 
     'PostOfficeBoxCity' => array('name'=>'PostOfficeBoxCity','type'=>'xsd:string'), 
     'PostOfficeBoxPostcode' => array('name'=>'PostOfficeBoxPostcode','type'=>'xsd:string'), 
     'CountryName' => array('name'=>'CountryName','type'=>'xsd:string'), 
     'CustomerOrigin' => array('name'=>'CustomerOrigin','type'=>'xsd:string'), 
     'Attention' => array('name'=>'Attention','type'=>'xsd:string'), 
     'Contact' => array('name'=>'Contact','type'=>'xsd:string'), 
     'ReceiverRef' => array('name'=>'ReceiverRef','type'=>'xsd:string'), 
     'OurRef' => array('name'=>'OurRef','type'=>'xsd:string'), 
     'MessageToCarrier' => array('name'=>'MessageToCarrier','type'=>'xsd:string'), 
     'MessageToDriver' => array('name'=>'MessageToDriver','type'=>'xsd:string'), 
     'MessageToReceiver' => array('name'=>'MessageToReceiver','type'=>'xsd:string'), 
     'PurchaseNo' => array('name'=>'PurchaseNo','type'=>'xsd:string'), 
     'ShipmentTypeNo' => array('name'=>'ShipmentTypeNo','type'=>'xsd:string'), 
     'ReceiverRef' => array('name'=>'ReceiverRef','type'=>'xsd:string'), 
     'DeliveryConditions' => array('name'=>'DeliveryConditions','type'=>'xsd:string'), 
     'DeliveryTime' => array('name'=>'DeliveryTime','type'=>'xsd:string'), 
     'PaymentTerms' => array('name'=>'PaymentTerms','type'=>'xsd:string'), 
     'Amount' => array('name'=>'Amount','type'=>'xsd:string'), 
     'Account' => array('name'=>'Account','type'=>'xsd:string'), 
     'Reference' => array('name'=>'Reference','type'=>'xsd:string'), 
     'Type' => array('name'=>'Type','type'=>'tns:AddressType') 
    ) 
); 

Dans cette fonction j'essaie d'utiliser la valeur Delivery, mais elle n'est pas définie. Il obtiennent toujours le client:

// ---- GetCustomerData ---------------------------------------------------------------- 

function GetCustomerData($CustomerNumber,$Credentials) { 



$prefix = $Credentials['UserName']; 
$outArray = array(); 

// Query for CustomerData. 
$result = mysql_query("SELECT c.customers_id , 
         CONCAT(a.entry_firstname, ' ', a.entry_lastname) AS Name , 
         a.entry_street_address , 
         a.entry_postcode , 
         a.entry_city , 
         customers_email_address , 
         c.customers_email_address , 
         c.customers_telephone , 
         c.customers_fax 
         FROM $prefix"."customers AS c 
         INNER JOIN $prefix"."address_book AS A 
         ON c.customers_default_address_id = a.address_book_id 
         WHERE c.customers_id =$CustomerNumber");      

while($row = mysql_fetch_array($result)) 
    { 
     $AddressData['Number'] = $row['customers_id']; 
     $AddressData['Name1'] = $row['Name']; 
     $AddressData['StreetAddress1'] = $row['entry_street_address']; 
     $AddressData['Postcode'] = $row['entry_postcode']; 
     $AddressData['City'] = $row['entry_city']; 
     $AddressData['Mobile'] = $row['customers_telephone']; 
     $AddressData['Email'] = $row['customers_email_address']; 
     $AddressData['Fax'] = $row['customers_fax']; 
     $AddressData['Reference'] = 'tester'; 


    } 

$AddressData['Type'] = $AddressType['Delivery'];---This line? 

$outArray[] = $AddressData; 

mysql_close($con); 

    // Return array 
    return $outArray; 
} 

Je fais mal ceci c'est sûr, mais quoi?

Répondre

1

Voilà comment je l'ai fait:

$server->wsdl->addSimpleType('MyDataType', 'xsd:string', 'SimpleType', 'scalar', 
    array(
    'Value1', 
    'Value2' 
    )); 

qui se traduit par les éléments suivants dans le wsdl

<xsd:simpleType name="MyDataType"> 
    <xsd:restriction base="xsd:string"> 
     <xsd:enumeration value="Value1"/> 
     <xsd:enumeration value="Value2"/> 
    </xsd:restriction> 
    </xsd:simpleType> 
</xsd:schema> 

il a obtenu des nusoap docs