我需要创建一个将订单上传到第三方提供商进行处理的客户端。这是wsdl链接:http://support.dqtech.com/DQIAuto_WS/service.asmx?WSDL
我在如何基于wsdl初始化数组时遇到问题。 到目前为止,我将Web服务设置为我的项目,并且可以从WSDl查看所有方法和属性。
我的想法是使用List并将其转换为Array并通过它,但是当我尝试循环并赋值时出现索引异常错误。 DQ是我的网络服务 任何帮助或不同的想法如何编写此代码? 这是我的代码的一部分:
using System.Web.Services.Protocols;
using System.Collections.Generic;
using System.Collections;
using OrderImport.DQ;
private void btnTransmit_Click(object sender, EventArgs e)
{
ServiceSoapClient client = new ServiceSoapClient("ServiceSoap");
List<cOrder> cOrderl = new List<cOrder>();
List<ArrayOfCOrderDetail> orderDetails = new List<ArrayOfCOrderDetail>();
List<cOrderDetail> cOrderDetails = new List<cOrderDetail>();
for (i=0; i < rowCount; i++)
{
iOrd += 1;
cOrderl[iOrd] = new DQ.cOrder
{
Company = "1",
Location = "LOC1",
OrderType = "O",
OrderNumber = dtOrders.Rows[i]["OrderNumber"].ToString(),
ShipmentNumber="",
InvoiceNumber= dtOrders.Rows[i]["InvNumber"].ToString(),
OrderDateTime= dtOrders.Rows[i]["OrderDate"].ToString(),
ReqDate="",
Changed="",
ChangeDateTime="",
PONumber= dtOrders.Rows[i]["ShortPO"].ToString(),
WrittenByName="",
WrittenByCode= dtOrders.Rows[i]["WritenBy"].ToString(),
SalesmanName="",
SalesmanCode= dtOrders.Rows[i]["SalesRepId"].ToString(),
Customer=new DQ.cCustomer
{
CustomerNumber= dtOrders.Rows[i]["CustomerId"].ToString(),
CustomerName= dtOrders.Rows[i]["CustName"].ToString(),
Address=new DQ.cAddress
{
Address1= dtOrders.Rows[i]["CustAddress1"].ToString(),
Address2= dtOrders.Rows[i]["CustAddress2"].ToString(),
City= dtOrders.Rows[i]["CustCity"].ToString(),
State= dtOrders.Rows[i]["CustState"].ToString(),
Zip= dtOrders.Rows[i]["CustZip"].ToString(),
Latitude=0,
Longitude=0
},
Contact=new DQ.cContact
{
Contact="",
Phone= dtOrders.Rows[i]["CustPhone"].ToString(),
Fax=""
},
SalespersonCode=""
},
Job=new DQ.cJob
{
Company="",
CustomerNumber= dtOrders.Rows[i]["CustomerId"].ToString(),
JobNumber= dtOrders.Rows[i]["ShipToId"].ToString(),
JobName= dtOrders.Rows[i]["ShipToName"].ToString(),
Address=new DQ.cAddress
{
Address1= dtOrders.Rows[i]["ShipToAddress1"].ToString(),
Address2= dtOrders.Rows[i]["ShipToAddress2"].ToString(),
City=dtOrders.Rows[i]["ShipToCity"].ToString(),
State= dtOrders.Rows[i]["ShipToState"].ToString(),
Zip= dtOrders.Rows[i]["ShipToZip"].ToString(),
Latitude=0,
Longitude=0
},
},
TotalAmount="",
TotalCost="",
WeightTotal= dtOrders.Rows[i]["OrderWeight"].ToString(),
VolumeTotal= dtOrders.Rows[i]["OrderCBF"].ToString(),
ShipVia= dtOrders.Rows[i]["Route"].ToString(),
MapZone= dtOrders.Rows[i]["Route"].ToString(),
Rating="",
Territory="",
//OrderDetail=orderDetailArray[]
};
}
}