ServiceStack hello world example not generating soap proxies

gnikolaropoulos

I just updated my references to the new ServiceStack from nuget (from 3.9.11 to version 3.9.56) and I could not get my soap clients to work. So I decided to try once again the Hello World solution provided on [github] (https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/ServiceStack.Hello) which by the way is using an older version (3.9.32).

I added the [DataContract] attributes on the Hello and HelloResponse classes and then I tried to build a C# console client by adding a service reference to my localhost soap12 endpoint (using the Add Service Reference on VS2010, also tried 2012 and 2013). Unfortunately while I do get the OneWayClient and the SyncReplyClient I do not get any of my DTOs generated. Why is that? I tried to build my code with an older version of ServiceStack (using the IService<T> and the Execute method and everything worked fine! Are there any breaking changes that I am not aware of?

P.S. I tried also to recompile the whole ServiceStack.Examples project against the nuget libraries and it failed too. I could not even generate the proxy. Please do not try to convince me to use a share assembly for my DTOs as this defeats the purpose of having a language agnostic web service!

gnikolaropoulos

I have finally solved the issue so I am going to post the answer here. ServiceStack is not as broken as it seems although all the examples on the github repo need an update to work with the latest version. So to the point: if you want your classes to correctly produce proxy classes you have to decorate them all not only with the [DataContract] attribute on the class level but also with the [DataMember] on the property level i.e.

[DataContract]
class User
{
    [DataMember]
    public String Name { get; set; }
}

Of course you also need to either specify the namespace on the [DataContract] attribute (for Mono compatibility) or you will have to add a few lines on the AssemblyInfo.cs as described here.

Be warned though! All your DTOs including request types and response types should be on the same namespace! Also if you define only first level classes as request types (like the User example I used) then you will not get a proxy class! Instead all the public members will become method parameters. If you had though, by composition, another public member within User class i.e.

[DataContract]
class User
{
    [DataMember]
    public String Name { get; set; }
    [DataMember]
    public MyClass MyMember { get; set; }
}

then you would get your proxies for the MyClass though not for User. As for response types better read the ServiceStack wiki on SOAP limitations.

Last note: I usually have strong opinions only about flexibility, simplicity, finding alternatives and making things work. I find pointless the discussions that try to support a language over another, an architecture over another, a buzzword/niche technology over a standard approach, using tools that make life easier over hardcoding everything. So I see as such the discussion on the comments above and I wish to continue no more.

I am just glad that a great tool like ServiceStack continues to provide what most users use it for: A variety of alternatives.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

MEDIAPIPE failed run hello world from example

From Dev

Why is the first "hello world" example in the django book not working?

From Dev

Simple TCPClient/Listener ("hello world") example

From Dev

Glass GDK High frequency LiveCard Hello, World example?

From Dev

Running the hello world OpenCL example on mac os x 10.9 Mavericks

From Dev

JointJS: Hello World example doesn't work

From Dev

"Hello World" in Openvms/Itanium assembly example?

From Dev

"Hello World" example for Slick 2.0 with MySQL

From Dev

Maven 3 Jenkins Plugin - "Build Failure" for Hello World example

From Dev

error in generating .ko file for simple hello world module for linux kernel

From Dev

Graphics driver "hello world" example?

From Dev

why does this "hello world" golang http example slow down on osx

From Dev

How to get started with ReactJS Hello World example?

From Dev

Spark: ClassNotFoundException when running hello world example in scala 2.11

From Dev

mithril hello world MVC example not working

From Dev

CMake - Code::Blocks - hello world - basic example

From Dev

Prelink Error: prelink-cross: simple hello world example

From Dev

Function arguments in node.js' Hello World example

From Dev

Node.js Error for Hello World example

From Dev

How to write a hello world example in AWS Lambda using Python 2.7?

From Dev

Generating proxies with Doctrine

From Dev

Spring hello world example error

From Dev

How to run Apple's OpenCL "Hello World" example in XCode

From Dev

MVC using Spring hello world example

From Dev

Calling Methods In Java - Hello World Example

From Dev

error in generating .ko file for simple hello world module for linux kernel

From Dev

AngularJS, $routeProvider and resolve: Hello World example not working

From Dev

How to get started with ReactJS Hello World example?

From Dev

Hello world minitest cli example

Related Related

  1. 1

    MEDIAPIPE failed run hello world from example

  2. 2

    Why is the first "hello world" example in the django book not working?

  3. 3

    Simple TCPClient/Listener ("hello world") example

  4. 4

    Glass GDK High frequency LiveCard Hello, World example?

  5. 5

    Running the hello world OpenCL example on mac os x 10.9 Mavericks

  6. 6

    JointJS: Hello World example doesn't work

  7. 7

    "Hello World" in Openvms/Itanium assembly example?

  8. 8

    "Hello World" example for Slick 2.0 with MySQL

  9. 9

    Maven 3 Jenkins Plugin - "Build Failure" for Hello World example

  10. 10

    error in generating .ko file for simple hello world module for linux kernel

  11. 11

    Graphics driver "hello world" example?

  12. 12

    why does this "hello world" golang http example slow down on osx

  13. 13

    How to get started with ReactJS Hello World example?

  14. 14

    Spark: ClassNotFoundException when running hello world example in scala 2.11

  15. 15

    mithril hello world MVC example not working

  16. 16

    CMake - Code::Blocks - hello world - basic example

  17. 17

    Prelink Error: prelink-cross: simple hello world example

  18. 18

    Function arguments in node.js' Hello World example

  19. 19

    Node.js Error for Hello World example

  20. 20

    How to write a hello world example in AWS Lambda using Python 2.7?

  21. 21

    Generating proxies with Doctrine

  22. 22

    Spring hello world example error

  23. 23

    How to run Apple's OpenCL "Hello World" example in XCode

  24. 24

    MVC using Spring hello world example

  25. 25

    Calling Methods In Java - Hello World Example

  26. 26

    error in generating .ko file for simple hello world module for linux kernel

  27. 27

    AngularJS, $routeProvider and resolve: Hello World example not working

  28. 28

    How to get started with ReactJS Hello World example?

  29. 29

    Hello world minitest cli example

HotTag

Archive