2010-10-28 2 views
1

У меня есть класс перечисления, и я хочу установить из него значение в функции. Но я не могу это сделать. Он всегда выбирает кулак в линию, ее клиент.Nusoap simpletype enumeration

$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') 
    ) 
); 

В этой функции я пытаюсь использовать значение «Доставка», но оно не установлено. Он по-прежнему получает:

// ---- 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; 
} 

Я делаю это неправильно, это точно, но что?

ответ

1

Вот как я это сделал:

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

что приводит следующее в WSDL

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

получил его от NuSOAP документы