我有一个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