Send a class object to a webservice
-
Hi all, I am trying to send a class to a web service but I get error SoapException was unhandled by user code System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. It happens when I call the webservice in the follwoing line info.sendInformation(createFile); here is my web method, [WebMethod] public void sendInformation(object info) { etc. } and my code to call it info createFile = new info(); createFile .Reference = txtReference.Text; createFile .AccountNo = txtAccountNo.Text; createFile info = new InfoService (); info.sendInformation(createFile); and the class public class fax : TestPage { public string Reference { get { return _Reference; } set { _Reference = value; } } public string AccountNo { get { return _AccountNo; } set { _AccountNo = value; } } etc. } Thanks
-
Hi all, I am trying to send a class to a web service but I get error SoapException was unhandled by user code System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Runtime.InteropServices.COMException (0x800706BA): The RPC server is unavailable. It happens when I call the webservice in the follwoing line info.sendInformation(createFile); here is my web method, [WebMethod] public void sendInformation(object info) { etc. } and my code to call it info createFile = new info(); createFile .Reference = txtReference.Text; createFile .AccountNo = txtAccountNo.Text; createFile info = new InfoService (); info.sendInformation(createFile); and the class public class fax : TestPage { public string Reference { get { return _Reference; } set { _Reference = value; } } public string AccountNo { get { return _AccountNo; } set { _AccountNo = value; } } etc. } Thanks
I'm pretty certain that
info createFile = new info();
createFile .Reference = txtReference.Text;
createFile .AccountNo = txtAccountNo.Text;
createFile info = new InfoService ();
info.sendInformation(createFile);doesn't compile. Can you clarify. And although I stand to be corrected, I'm pretty sure you can't send Object to a web service, it needs definition. Make your service accept an Info object or Fax as it is.
-
I'm pretty certain that
info createFile = new info();
createFile .Reference = txtReference.Text;
createFile .AccountNo = txtAccountNo.Text;
createFile info = new InfoService ();
info.sendInformation(createFile);doesn't compile. Can you clarify. And although I stand to be corrected, I'm pretty sure you can't send Object to a web service, it needs definition. Make your service accept an Info object or Fax as it is.
Sorry I copied it wrong, the following is the correct one and compiles fine info createFile = new info(); createFile .Reference = txtReference.Text; createFile .AccountNo = txtAccountNo.Text; InfoService info = new InfoService (); info.sendInformation(createFile); Even if I define the same class in the web service still doesn't work because is different namespace. Thanks
-
Sorry I copied it wrong, the following is the correct one and compiles fine info createFile = new info(); createFile .Reference = txtReference.Text; createFile .AccountNo = txtAccountNo.Text; InfoService info = new InfoService (); info.sendInformation(createFile); Even if I define the same class in the web service still doesn't work because is different namespace. Thanks
Ok. In your web service, define your class. Then accept the type of Fax in your sendInformation method of the WS. Now, when you consume the web service, a type of Fax will become available. Visual studio creates code files to represent the objects you can pass up so, without you physically defining the file locally, you can;
Fax createFile = new Fax( );
createFile.Reference = txtReference.Text;
createFile.AccountNo = txtAccountNo.Text;InfoService info = new InfoService( );
info.SendInformation( createFile );
Where your WS method looks like;
[WebMethod]
public void SendInformation( Fax info)
{
// do something with info in here
}