August 20, 2007, 10:31 AM
MichealPassing parameters in a web service
Hello,
I am trying to use web services to run a report and pass in a parameter. The problem I have is I'm using C# and the code examples are in VB. For this reason I'm getting a casting error and can't work out how to resolve it.
The code is here (I've highlighted the offending line that I can't resolve):
WebFocusWs.WebFocus wfs = new WebFocusWs.WebFocus();
WebFocusWs.LogOnInfo logon = new WebFocusWs.LogOnInfo();
WebFocusWs.WebFocusReturn ret = new WebFocusWs.WebFocusReturn();
WebFocusWs.FexInfo report = new WebFocusWs.FexInfo();
WebFocusWs.ValuesArrayEntry param = new WebFocusWs.ValuesArrayEntry();
string newOutput = String.Empty;
// create parameter value
Array paramList = Array.CreateInstance(typeof(WebFocusWs.ValuesArrayEntry), 2);
param.name = "CUSTOMERACCOUNTNUMBER";
param.val = "111111111";
paramList.SetValue(param, 0);
report.server = "EDASERVE";
report.app = "MBC";
report.name = "billingData1";
report.IBIWS_arrayvalues = paramList.GetValue(0); logon = wfs.WebFocusLogOn("[userId]", "[password]", "", "");
ret = wfs.WebFocusRunFex(logon, report);
newOutput = ret.output;
litReport.Text = newOutput;
I would be grateful for any advice on solving this.
thanks
Micheal
August 20, 2007, 01:13 PM
dhagenI'm no .Net guy, but shouldn't the report.IBIWS_arrayvalues be done after the logon action?
August 21, 2007, 05:38 AM
MichealHello,
I've worked it out. The following line does the trick:
report.IBIWS_arrayvalues = (WebFocusWs.ValuesArrayEntry[])paramList;
Micheal
August 21, 2007, 04:56 PM
<JimW>This is a good resource for converting VB.NET code to C#...
http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx