我有一個WSDL文檔,它有上面這樣的元素。WSDL元素爲空?
<s:element name="NewPortalOrder">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="OrderType" type="tns:CardSalesType" />
<s:element minOccurs="1" maxOccurs="1" name="Customer" type="tns:PortalCustomerContainer" />
<s:element minOccurs="1" maxOccurs="1" name="InvoiceAddress" type="tns:AddressContainer" />
<s:element minOccurs="1" maxOccurs="1" name="DeliveryAddress" type="tns:AddressContainer" />
<s:element minOccurs="0" maxOccurs="1" name="Cards" type="tns:ArrayOfPortalCardContainer" />
</s:sequence>
</s:complexType>
</s:element>
我將WSDL文件作爲ServiceReference添加到解決方案中。
在服務器端
WS.NewPortalOrderRequest order = new WS.NewPortalOrderRequest();
order.InvoiceAddress.AddressLine1 = txtAddress.Text;
order.InvoiceAddress.AddressLine2 = txtAddress2.Text;
在order.InvoiceAddress.AddressLine1 = txtAddress.Text;
線我得到的Object reference not set to an instance of an object.
錯誤。
當我看order.InvoiceAddress
時,我看到它是空的。爲什麼我可以得到這個錯誤?我該如何解決它?
你是如何創建'order.InvoiceAdress'?你能顯示完整的代碼嗎? – Tim 2013-04-30 08:09:36
我將它添加到問題@Tim – 2013-04-30 08:12:51
幾乎所有'NullReferenceException'的情況都是一樣的。請參閱「[什麼是.NET中的NullReferenceException?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)」的一些提示。 – 2013-04-30 08:24:48