实例化Web服务C#、. NET [英] Instantiating a web service, c#, .net

查看:99
本文介绍了实例化Web服务C#、. NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.我在了解如何将数据发送到Web服务时遇到问题.
错误:使用未分配的局部变量"myCCAuthRequest"
如何正确准备要发送到Web服务的字符串?

Hello. I''m having an issue understanding how to send the data to a web service.
Error: Use of unassigned local variable ''myCCAuthRequest''
How do I properly prepare the string to send to the web service?

protected void ButtonContinuePayment_Click(object sender, EventArgs e)
        {      
            testwebservice.Request_Return_Parms rrRequest = new testwebservice.Request_Return_Parms();
            testwebservice.CCAuthRequest myCCAuthRequest;           

            string MerchantID = "MYMERCHID";
            decimal AuthorizationAmount = Convert.ToDecimal(litFee.Text);
            string OneStepTranType = "TRANTYP1";
            string ApplicationIDPrimary = litRegID2.Text;
            string ReturnURL = "https://mysite.com/Confirm.aspx";
            int AuthorizationAttemptLimit = 2;
            string ApplicationIDSecondary = "SecondID";  
            string ApplicationStateData = "StateData";
            string StyleSheetKey = "11f15af0a02999";
            string EmailAddressDeptContact = "jane.doe@mysite.com";

            try
            {                
                if (rrRequest.RequestReturnCode == 0)
                {   
//this is where I''m getting the error. Use of unassigned local variable ''myCCAuthRequest''	
                   rrRequest = myCCAuthRequest.AuthCapRequest(MerchantID, AuthorizationAmount, OneStepTranType, ApplicationIDPrimary, ReturnURL, AuthorizationAttemptLimit, ApplicationIDSecondary, ApplicationStateData, StyleSheetKey, EmailAddressDeptContact);
                }
            }
            catch
            {
                Response.Write("Error Processing payment");
            }
        }

推荐答案

这与Web服务或除基本编码之外的其他任何事情均无关.

您在方法的第二行中声明myCCAuthRequest,然后不做任何赋值,直到在try...catch块中使用它为止.

错误消息甚至告诉您您在做什么错!
This has nothing to do with web services, or anything else really - other than basic coding.

You declare myCCAuthRequest in the second line of the method, then do nothing to give it a value until you use it in teh try...catch block.

The error message even tells you what you are doing wrong!
Use of unassigned local variable 'myCCAuthRequest'

您需要为其分配一个值-可能与rrRequest有关,但这取决于您.

You need to assign it a value - probably something to do with rrRequest, but that is up to you.


这篇关于实例化Web服务C#、. NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆