I'd really appreciate some advice here. I've been trying to get an api call using c# and cwbx.dll. It seems right, but debugging it is pretty difficult.
Could anyone shed some light on how I would debug it if say.... the website never finished loading? I usually get a return code of null on the error parameter.
Code:
private void apiCall(){ string result =string.Empty; StringConverter stringConverter =new StringConverterClass(); // Define an AS400 system and connect to it AS400System system = new AS400System(); system.Define(ipaddress); system.UserID=user; system.Password=password; system.IPAddress=ipaddress; system.Connect(cwbcoServiceEnum.cwbcoServiceRemoteCmd); // Check the connection if(system.IsConnected(cwbcoServiceEnum.cwbcoServiceRemoteCmd)==1) { // Create a program object and link to a system cwbx.Program program =new cwbx.Program(); program.LibraryName = library; program.ProgramName = program; program.system=system; ProgramParameters parameters = new ProgramParameters(); parameters.Append("error", cwbrcParameterTypeEnum.cwbrcInout, 80); parameters.Append("ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80); parameters.Append("$error", cwbrcParameterTypeEnum.cwbrcInout, 80); parameters.Append("$ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80); parameters.Append("&error", cwbrcParameterTypeEnum.cwbrcInout, 80); parameters.Append("&ERROR", cwbrcParameterTypeEnum.cwbrcInout, 80); parameters.Append("ahpro", cwbrcParameterTypeEnum.cwbrcInout, 11); parameters["ahpro"].Value = stringConverter.ToBytes(inputProNumber.Text.Trim().PadRight(11, ' ')); try { program.Call(parameters); } catch(Exception ex) { if(system.Errors.Count>0) { foreach(cwbx.Error error in system.Errors) { Response.Write("System: " + error.Text + "<br />"); System.Diagnostics.Debug.WriteLine(error.Text); } } if(program.Errors.Count>0) { foreach(cwbx.Error error in program.Errors) { Response.Write("Program: " + error.Text + "<br />"); System.Diagnostics.Debug.WriteLine(error.Text); } } } result = stringConverter.FromBytes(parameters["error"].Value); Response.Write("result is " + result + "<br />"); result = stringConverter.FromBytes(parameters["ERROR"].Value); Response.Write("RESULT is " + result + "<br />"); result = stringConverter.FromBytes(parameters["$error"].Value); Response.Write("$result is " + result + "<br />"); result = stringConverter.FromBytes(parameters["$ERROR"].Value); Response.Write("$RESULT is " + result + "<br />"); result = stringConverter.FromBytes(parameters["&error"].Value); Response.Write("&result is " + result + "<br />"); result = stringConverter.FromBytes(parameters["&ERROR"].Value); Response.Write("&RESULT is " + result + "<br />"); } system.Disconnect(cwbcoServiceEnum.cwbcoServiceAll); System.Diagnostics.Debug.WriteLine(result); Response.Write("result is " + result);
Comment