2012-12-05 23 views
3

我有一個來自我的客戶及其wsdl文件的web服務URL。我從wsdl文件中添加了一個新項目。'date'對於SoapElementAttribute是無效的值

在WSDL

<element name="ProductionDate" type="xsd:date" minOccurs="0" maxOccurs="1" nillable="true"/> 

在reference.cs文件

[System.Xml.Serialization.SoapElementAttribute("ProductionDate", DataType="date",  IsNullable=true)] 
public System.Nullable<System.DateTime> ProductionDate{ 
get { 
    return this.ProductionDate; 
} 
set { 
    this.ProductionDate= value; 
} 
} 

當我嘗試創建WebService類的實例,它拋出一個異常:

'日期' 是SoapElementAttribute的值無效。

我在WSDL改變

[System.Xml.Serialization.SoapElementAttribute("ProductionDate", DataType="date")] 
public System.DateTime ProductionDate{ 
get { 
    return this.ProductionDate; 
} 
set { 
    this.ProductionDate= value; 
} 
} 

所以我可以創建WebService類的實例,但是,當我從我的客戶web服務URL調用,拋出一個異常:

法「Q1:布拉布拉未實現:方法名稱或命名空間不是 已識別。

那麼還有什麼其他方式可以使這個工作嗎?

回答

0

我相信你必須在.cs文件中爲日期數據類型在xsd模式文件中使用數據類型'dateTime'。

試試這個

SoapElement(DataType = "dateTime") 
相關問題