我有一个 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
,我发现那是空的。为什么我会收到此错误?我该如何解决?