scripsharp reference web service / strongly type to results model

Posted by user175528 on Stack Overflow See other posts from Stack Overflow or by user175528
Published on 2011-01-07T01:47:25Z Indexed on 2011/01/07 1:54 UTC
Read the original article Hit count: 470

Filed under:

With scriptsharp (script#) is it possible to get strong typing when calling a service defined in my web app? The only way I can see is to:
1 - use linked / shared files to shadow copy my results classes / domain models across into my script# lib
2 - replicate my model across in the script# lib and use automapper to validate?
3 - use some .tt to code gen?

also, even if I can do this, how do I get around the auto camel-casing script# does, when my service result (asmx) wont do this? (so my JSON response will comback as UserMessage, script# will have changed that to userMessage)

basically, what I am looking to use script# to achieve is better compile time support against our domain model when calling and processing services in javascript, so something like this:

Scriptlet
public static class MyScriptlet {
public static void Main() { MyService.Service1("hello", ProcessResponse);}
public static void ProcessResponse(MyService.Service1ResponseData resp) {
jQuery.Select('#Message').Text(resp.UserMessage);
jQuery.Select('#Detail').Text(resp.UserDetail);
}

Service (in our web app)
public class MyService { public class Service1ResponseData { public string UserMessage {get;set;} public string UserDetail {get;set;} } public Service1ResponseData Service1(string user) { return new Service1ResponseData() { UserMessage:"hi",UserDetail:"some text"}; } }

© Stack Overflow or respective owner

Related posts about script#