Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Data transfer

    I'm still very new to .NET. I managed to write a web service using
    managed extensions for C++ and integrate it with existing business
    logic. The web client is written in C#. To receive bunch of strings
    from the server, the client does this:

    String [] n = ws.GetEmployeeInfo (empno);
    Name.Text = n [0];
    Department.Text = n [1];
    Type.Text = n [2];
    Period.Text = n [3];
    PayType.Text = n [4];
    PayRate.Text = n [5];
    CheckDate.Text = n [6];

    This works, but now I need to retrieve more hetrogeneous data. What I
    would like to do is create a class and pass it from the service to the
    client (and vice versa at times). So the code would then look more
    like:

    MyClass data = ws.GetEmployeeInfo (empno);
    Name.Text = data.Name;
    Department.Text = data.Dept;

    etc, and then I could have other data types in the class such as bool
    and double..

    My problem is how does the C++ service and the C# client each know
    what the class looks like? Is there a way to put the class definition
    in a header file and include it in both sources? I realize that the
    data is passed via XML and so the field names and types are passed,
    but again, how do I tell the server to use a class that the client
    will understand?

    I have tried to understand the concept of a dataset and see if it
    could be used, but it incapsulates way more functionality than I need,
    and I still don't see how the C++ web service can know what it looks
    like, and how to fill it. This data does not come out of a relational
    database, so using SQL, OleDB and OBDC does not make any sense (at
    least to me).

    Thanks for any help.

    Russ
    Russ Guest

  2. Similar Questions and Discussions

    1. Unable to transfer data
      I have a connection problem in Contribute. The first time I connected it worked just fine. The second time it didn't work anymore. It shows an...
    2. Batch Transfer data into
      I'm not sure if this is the right forum... I have a file with basically 2 fields - filename and subject - and 1000s of records I have 1000s of...
    3. How do I transfer data from one pg to the next pg?
      I have a registration page that I would like to go to a welcome page when registration is complete. The welcome page will say "Welcome (name) your...
    4. perl data transfer
      SRam wrote: TCP streams? Have a look at the Net:: family of modules via search.cpan.org Steffen -- @n=(,,,,,);$b=6;@c=' -/\_|'=~/./g...
    5. How to transfer data files...
      I need help on file transfers, to and from, web servers to remote user computers. If anyone knows of a good reference I'd appreciate the tip. If...
  3. #2

    Default Re: Data transfer



    "Russ" <russk2@eticomm.net> wrote in message
    news:broeb0duam423u01hfio2jj11vrausliel@4ax.com...
    > I'm still very new to .NET. I managed to write a web service using
    > managed extensions for C++ and integrate it with existing business
    > logic. The web client is written in C#. To receive bunch of strings
    > from the server, the client does this:
    >
    > String [] n = ws.GetEmployeeInfo (empno);
    > Name.Text = n [0];
    > Department.Text = n [1];
    > Type.Text = n [2];
    > Period.Text = n [3];
    > PayType.Text = n [4];
    > PayRate.Text = n [5];
    > CheckDate.Text = n [6];
    >
    > This works, but now I need to retrieve more hetrogeneous data. What I
    > would like to do is create a class and pass it from the service to the
    > client (and vice versa at times). So the code would then look more
    > like:
    >
    > MyClass data = ws.GetEmployeeInfo (empno);
    > Name.Text = data.Name;
    > Department.Text = data.Dept;
    >
    In C#, I would code a webmethod that does this, like so:

    public class MyClass {
    public string Name;
    public int Dept;
    public bool Verified;
    public AnotherClass[] ArrayOfSomething;
    // etc....
    }

    [WebService]
    public class MyService {
    [webMethod]
    public MyClass GetEmployeeInfo(int empno) {
    ....
    }
    }

    Sorry I don't know the C++ syntax.

    > My problem is how does the C++ service and the C# client each know
    > what the class looks like? Is there a way to put the class definition
    > in a header file and include it in both sources?
    Yes, such classes as are used in the webservice are included in the WSDL
    (Webservices Definition Language), which is like an IDL (Interface
    Definition language) file if you know CORBA or DCE. For the client-proxy
    generation, you run "Add Web Reference" in visual studio, or you run
    wsdl.exe if you develop with just the .NET SDK. You pass in the WSDL to
    either of these, and the output is a client proxy, complete with a generated
    version of "MyClass".


    > how do I tell the server to use a class that the client
    > will understand?
    >
    You don't. You generate a class for use within the client according to the
    published interface (the WSDL).

    maybe this will help?

    -Dino



    Dino Chiesa [Microsoft] Guest

  4. #3

    Default Re: Data transfer

    Dino, thanks for your response. Having had the long holiday weekend
    to mull it over I had come to the conclusion that I should try
    something about like you showed. So I will try it and see if it
    works. The only part that confuses me is in the client, where you do:
    > public MyClass GetEmployeeInfo(int empno) {
    How does the client C# code know what MyClass looks like? I guess
    this is some magic of the SOAP protocol, but I know that in C++ if I
    tried to do that without declaring and defining the class first, I
    would get a compile error.

    Still, I will try it shortly (and report back here if I still cannot
    make it work.)

    Trying to learn about web programming AND C# at the same time is a
    bear...

    Thanks again, Russ


    On Tue, 1 Jun 2004 15:55:03 -0400, "Dino Chiesa [Microsoft]"
    <dinoch@online.microsoft.com> wrote:
    >
    >
    >"Russ" <russk2@eticomm.net> wrote in message
    >news:broeb0duam423u01hfio2jj11vrausliel@4ax.com.. .
    >> I'm still very new to .NET. I managed to write a web service using
    >> managed extensions for C++ and integrate it with existing business
    >> logic. The web client is written in C#. To receive bunch of strings
    >> from the server, the client does this:
    >>
    >> String [] n = ws.GetEmployeeInfo (empno);
    >> Name.Text = n [0];
    >> Department.Text = n [1];
    >> Type.Text = n [2];
    >> Period.Text = n [3];
    >> PayType.Text = n [4];
    >> PayRate.Text = n [5];
    >> CheckDate.Text = n [6];
    >>
    >> This works, but now I need to retrieve more hetrogeneous data. What I
    >> would like to do is create a class and pass it from the service to the
    >> client (and vice versa at times). So the code would then look more
    >> like:
    >>
    >> MyClass data = ws.GetEmployeeInfo (empno);
    >> Name.Text = data.Name;
    >> Department.Text = data.Dept;
    >>
    >
    >In C#, I would code a webmethod that does this, like so:
    >
    > public class MyClass {
    > public string Name;
    > public int Dept;
    > public bool Verified;
    > public AnotherClass[] ArrayOfSomething;
    > // etc....
    > }
    >
    > [WebService]
    > public class MyService {
    > [webMethod]
    > public MyClass GetEmployeeInfo(int empno) {
    > ....
    > }
    > }
    >
    >Sorry I don't know the C++ syntax.
    >
    >
    >> My problem is how does the C++ service and the C# client each know
    >> what the class looks like? Is there a way to put the class definition
    >> in a header file and include it in both sources?
    >
    >Yes, such classes as are used in the webservice are included in the WSDL
    >(Webservices Definition Language), which is like an IDL (Interface
    >Definition language) file if you know CORBA or DCE. For the client-proxy
    >generation, you run "Add Web Reference" in visual studio, or you run
    >wsdl.exe if you develop with just the .NET SDK. You pass in the WSDL to
    >either of these, and the output is a client proxy, complete with a generated
    >version of "MyClass".
    >
    >
    >
    >> how do I tell the server to use a class that the client
    >> will understand?
    >>
    >
    >You don't. You generate a class for use within the client according to the
    >published interface (the WSDL).
    >
    >maybe this will help?
    >
    >-Dino
    >
    >
    Russ Guest

  5. #4

    Default Re: Data transfer

    > works. The only part that confuses me is in the client, where you do:
    >
    > > public MyClass GetEmployeeInfo(int empno) {
    >
    > How does the client C# code know what MyClass looks like? I guess
    Maybe you figured this out by now but....that GetEmployeeInfo method is
    exposed in the WSDL, which is the interface definition. When you build the
    client, you run wsdl.exe (or "Add Web Ref") and the client-side proxy class
    that is generated includes a definition for MyClass.



    Dino Chiesa [Microsoft] Guest

  6. #5

    Default Re: Data transfer

    Yes, I did figure it out. Thanks much for your help.

    Russ

    On Wed, 2 Jun 2004 15:22:15 -0400, "Dino Chiesa [Microsoft]"
    <dinoch@online.microsoft.com> wrote:
    >> works. The only part that confuses me is in the client, where you do:
    >>
    >> > public MyClass GetEmployeeInfo(int empno) {
    >>
    >> How does the client C# code know what MyClass looks like? I guess
    >
    >Maybe you figured this out by now but....that GetEmployeeInfo method is
    >exposed in the WSDL, which is the interface definition. When you build the
    >client, you run wsdl.exe (or "Add Web Ref") and the client-side proxy class
    >that is generated includes a definition for MyClass.
    >
    >
    Russ Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139