467,927 Members | 1,868 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,927 developers. It's quick & easy.

parameters passed to web service(WS) appear to be nulls on WS side

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.

Jul 31 '06 #1
  • viewed: 1014
Share:
1 Reply
Try it without your byte[] first parameter and see if it works.

John
Aug 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Marko | last post: by
reply views Thread by Fernando | last post: by
1 post views Thread by bambam | last post: by
10 posts views Thread by silverbob | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.