Call Webservice with Class

G

GarthK

I'm new at WS but having fun (for the most part) using RC1 of VS2005.
The following code is the sum total (so far) of the Web Services layer
on my 2003 IIS box. Behind this is a DLL that contains the actual class
definitions that are referenced here. I have a client that is
successfully invoking the GetVendor method and I can use the returned
Vendor object just fine. However, if I immediately follow the GetVendor
call with a call to PutVendor passing the Vendor parameter returned from
GetVendor, I get the following error on the client:

Server was unable to process request. ---> Failed to convert parameter
value from String to Int32. ---> Input string was not in correct format.

at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)

followed by a long list of calls.



using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using OESLib;


/// <summary>
/// Summary description for VendorWS
/// </summary>
[WebService(Namespace = "http://tigertechus.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class VendorWS : System.Web.Services.WebService
{

public VendorWS()
{

//Uncomment the following line if using designed components
//InitializeComponent();

}
[WebMethod]
public Vendor GetVendor(String VN)
{
return new Vendor(ref VN);
}

[WebMethod]
public bool PutVendor(Vendor v)
{
v.Save();
return true;
}

}

Pretty simple so far but I've had no luck figuring out what is wrong.

Ideas/thoughts greatly appreciated...

Thanx,
Garth
 
G

GarthK

GarthK said:
I'm new at WS but having fun (for the most part) using RC1 of VS2005.
The following code is the sum total (so far) of the Web Services layer
on my 2003 IIS box. Behind this is a DLL that contains the actual class
definitions that are referenced here. I have a client that is
successfully invoking the GetVendor method and I can use the returned
Vendor object just fine. However, if I immediately follow the GetVendor
call with a call to PutVendor passing the Vendor parameter returned from
GetVendor, I get the following error on the client:

Server was unable to process request. ---> Failed to convert parameter
value from String to Int32. ---> Input string was not in correct format.

at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)

followed by a long list of calls.



using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using OESLib;


/// <summary>
/// Summary description for VendorWS
/// </summary>
[WebService(Namespace = "http://tigertechus.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class VendorWS : System.Web.Services.WebService
{

public VendorWS()
{

//Uncomment the following line if using designed components
//InitializeComponent();

}
[WebMethod]
public Vendor GetVendor(String VN)
{
return new Vendor(ref VN);
}

[WebMethod]
public bool PutVendor(Vendor v)
{
v.Save();
return true;
}

}

Pretty simple so far but I've had no luck figuring out what is wrong.

Ideas/thoughts greatly appreciated...

Thanx,
Garth

Update:

Here is the code that seems to work based on serializing an XML string,
passing the string, and deserializing it on the WS side. Is this really
the best way to do this?

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using OESLib;
using System.Xml;
using System.Xml.Serialization;
using System.Text;
using System.IO;


/// <summary>
/// Summary description for VendorWS
/// </summary>
[WebService(Namespace = "http://tigertechus.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class VendorWS : System.Web.Services.WebService
{

public VendorWS()
{

//Uncomment the following line if using designed components
//InitializeComponent();

}
[WebMethod]
public Vendor GetVendor(String VN)
{
return new Vendor(ref VN);
}

[WebMethod]
public bool PutVendor(String vstr)
{
Vendor v = new Vendor();
StringReader Input = new StringReader(vstr);
XmlSerializer x = new XmlSerializer(v.GetType());
v = (Vendor)x.Deserialize(Input);
v.Save();
return true;
}

}

Here is the code that does the serialization:

StringWriter Output = new StringWriter(new StringBuilder());
string Ret = "";

XmlSerializer s = new XmlSerializer(v.GetType());
s.Serialize(Output, v);
Ret = Output.ToString();

bool saved = vw.PutVendor(Ret);

Again, seems to work.

Ideas/helpful hints appreciated.

Thanx,
Garth
 
K

Kumar Shetgar

This doesnt give clear picture of what the vendor class is like.
Obviously you are passing in something that it doesnt like.
Looking at the error, it might be trying to parse string into integer.
Check out if there are any conversions being done anywhere.
or post Vendor details. Hope that helps.

-- Kumar Shetgar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top