i've got the following simple webservice :
[WebMethod()]
public int Add(int a)
{
return a + 1;
}
i've created a class to call it (without creating a wsdl and then a proxy). something like:
[System.Web.Services.WebServiceBindingAttribute(
Name = "Addrequest",
Namespace = "GenieSoft")]
public class Addrequest :
System.Web.Services.Protocols.SoapHttpClientProtocol
{
public Addrequest()
{
this.Url = "http://localhost:3880/SoapService/Service.asmx";
}
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
"GenieSoft/Add",
RequestNamespace = "GenieSoft",
ResponseNamespace = "GenieSoft",
Use = System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public object[] Add(int a )
{
object[] results = this.Invoke("Add",new object[] { a });
return results;
}
}
i create an object of the class and then try to call the webservice as follows:
Addrequest request = new Addrequest();
object[] returnedArray = request.Add(1);
//object i = returnedArray[0]; // i is equal to {object[0]} !
lblresult.InnerText = returnedArray[0].ToString();
i've tested it with debug locally and the webservice is getting called and receiving the sent int "1" and returning "2" , however when i try to check the returnedArray all i find is {object[0]} which as i understand is another array of size 0 .
Can someone help me, by pointing out the problem ?
Note: i got this example of the book Programming Web Applications with Soap by O'Reilly , i only changed it from string to int , and i've tested it both ways -as a string and as an int- and got the same result for both tests.