Nusoap simpletype枚举

时间:2010-10-28 17:00:37

标签: php nusoap

我有一个枚举类,我想在函数中设置valuse。但我不是这样做的。它总是挑选拳头,她是客户。

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

在此函数中,我尝试使用值Delivery,但未设置。它仍然得到了客户:

// ---- 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 个答案:

答案 0 :(得分: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文档中获取