Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Send a class object to a webservice

Send a class object to a webservice

Scheduled Pinned Locked Moved C#
sysadminhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Gktony
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • G Gktony

      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

      H Offline
      H Offline
      hammerstein05
      wrote on last edited by
      #2

      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.

      G 1 Reply Last reply
      0
      • H hammerstein05

        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.

        G Offline
        G Offline
        Gktony
        wrote on last edited by
        #3

        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

        H 1 Reply Last reply
        0
        • G Gktony

          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

          H Offline
          H Offline
          hammerstein05
          wrote on last edited by
          #4

          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
          }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups