net 调用java_C#.Net 调用Java的Web Service

首先,得有一个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;

GiftCardResponse giftCardResponse = ocss.giftCard(gcr);

}

}

}

需要注意的一点是,

vs在解析时,会把int,long,double,DateTime等变量解析成改变量名与改变量名加Specified的形式,只要把要传的参数对应的Specified的值=true,这样就能传过去了,否则,这些类型的参数传不过去

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值