首先,得有一个web service地址:
http://www.baiduc.om/XXServices?wsdl
然后在.net 项目中添加Web引用,并把地址给它输进去
第三、编码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebServicesTest.XXServices;
namespace WebServicesTest
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GiftCardRequest gcr = new GiftCardRequest();
gcr.orderRequestId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
gcr.userName = "9001373";
gcr.applyType = 1;
gcr.applyTypeSpecified = true;
gcr.saleId = null;
gcr.recordNum = 1;
gcr.recordNumSpecified = true;
GiftCardInfo[] gcis = new GiftCardInfo[gcr.recordNum];
GiftCardInfo gci = new GiftCardInfo();
gci.cardType = "cardtype_vc_461999";
gci.cardValue = 10000;
gci.cardValueSpecified = true;
gci.cardCount = 1;
gci.cardCountSpecified = true;
gci.cardTotalValue = 10000;
gci.cardTotalValueSpecified = true;
gci.giftValue = 0;
gci.giftValueSpecified = true;
gcis[0] = gci;
gcr.cardInfo = gcis;
XXServices.XXServicesocss = new XXServices.XXServices();
GiftCardResponse giftCardResponse = ocss.giftCard(gcr);
}
}
}
需要注意的一点是,
vs在解析时,会把int,long,double,DateTime等变量解析成改变量名与改变量名加Specified的形式,只要把要传的参数对应的Specified的值=true,这样就能传过去了,否则,这些类型的参数传不过去