Hello everybody.
I came across this question before but there was no suitable answer. Since I
have the same problem, I will repeat it here.
this is a simple web servive:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Data;
using System.Data.SqlClient;
[WebService(Namespace = "http://tempns.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SomeWebService : System.Web.Services.WebService
{
public const string sInsertQry =
@"insert into [Images] ([Image], [StringField], [BoolField])
values (@pImg, @pStr, @pBool)";
public const string sConnStr =
@"Data Source=MYCOMP\SQLEXPRESS;Initial Catalog=MYDB;Integrated
Security=True;Pooling=False";
public SomeWebService() {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string Test() {
return "Test succeeded.";
}
[WebMethod]
public int PutImage(byte[] pImg, string pStr, bool pBool)
{
SqlConnection conn = new SqlConnection(sConnStr);
SqlCommand comm = new SqlCommand(sInsertQry, conn);
comm.Parameters.Add("@pImg", SqlDbType.VarBinary,
Int32.MaxValue).Value = pImg;
comm.Parameters.Add("@pStr", SqlDbType.VarChar,
Int32.MaxValue).Value = pStr;
comm.Parameters.Add("@pBool", SqlDbType.Bit).Value = pBool;
conn.Open();
int n = comm.ExecuteNonQuery();
conn.Close();
return n;
}
}
when I call PutImage method from a client app:
int n = ws.PutImage(bin_data, str_data, bool_option);
where bin_data and str_data are not null, they become nulls on web service
side:
public int PutImage(byte[] pImg, string pStr, bool pBool)
{
at this point debbugger says: pImg = null, pStr = null.
Where could the problem lie?
Any help will be truly appreciated.