in

Community Blogs

Blogs of different SQL/Developers Community Members

This Blog

Syndication

DamirDobric

rujan 2009 - Posts

  • Customizing Ado.Net DataService Operations

    When working with ADO.NET Data Service based on Entity Framework provide you can really build up from the scratch in just few minutes service based access to any kind of relational data.
    This can be very useful in many different application, but…
    If you build serious software you will for sure need to do something in your data service, which is not provided out of the box. Unfortunately, because you did nothing to build up the service, there are not to many options to do something This might be painful.

     

    For example, imagine you want to provide custom service operation GetCityNames which returns your custom type: MyEntity

    [WebGet]public IQueryable<MyEntity> GetMyEntities()


    When you try to start the service (open service URI in explorer) following error appears:

    Method 'System.Linq.IQueryable`1[SampleDataService.MyEntity] GetMyEntities(System.String, System.String)' has a return type 'System.Linq.IQueryable`1[SampleDataService.MyEntity]' which is not supported for service operations.  Only IQueryable and IEnumerable generics of primitive types or entity types are supported as return types.

    This means, you cannot use any complex custom type in the service.

     

    The good news is that there is a method “RegisterKnownType”  which allows you to register your custom type:

    config.RegisterKnownType(typeof(MyEntity));


    The bad news is that it doesn’t work with Entity Framework provider. :(

     

    Ok, but you think you could create the operation which use some EF-Type:

    [WebGet] public IQueryable<City> GetBigCities(List<int> someInput);


    This one fails with following error:


    Method 'System.Linq.IQueryable`1[SampleDataService.City] GetBigCities(System.Collections.Generic.List`1[System.Int32])' has a parameter 'System.Collections.Generic.List`1[System.Int32] stations' of type 'System.Collections.Generic.List`1[System.Int32]' which is not supported for service operations. Only primitive types are supported as parameters.

    The problem is that input parameter can be only of primitive types. List<int> is not such one. :(

    But, there is one thing you can do:

    [WebGet] public IQueryable<City> GetBigCities(int someInput);

    This will work

    Posted ruj 25 2009, 11:36 by anonymous
    Filed under:
  • Septembar 2009: Downloads for developers

     

    BinScope Binary Analyzer

    BinScope is a Microsoft verification tool that analyzes binaries on a project-wide level to ensure that they have been built-in compliance with Microsoft's Security Development Lifecycle requirements and recommendations

     

     

    Microsoft XNA Game Studio 3.1 Zune Extensions

    This release adds extensions to XNA Game Studio 3.1 to target and develop for the Zune HD media player

     

     

    Microsoft Anti-Cross Site Scripting Library V3.1

    This download helps you to protect your current applications from cross-site scripting attacks, at the same time helping you to protect your legacy application with its Security Runtime Engine

     

     

    IIS Database Manager Release Candidate (x86)

    IIS Database Manager allows you to easily manage your local and remote databases from within IIS Manager

     

     

    IIS Database Manager Release Candidate (x64)

    IIS Database Manager allows you to easily manage your local and remote databases from within IIS Manager

  • Ado.Net Data Services Request Errors

    When working with ADO.NET Data Services you might be suppressed how simple data entities can be exposed as services. However, when you start to dig deeper into framework by building of more complex code, you might be disappointed when you get errors like this one:

    “The server encountered an error processing the request. See server logs for more details.”

    One more nothing saying error? Yes it is, definitely

    I figured out that following pattern could be helpful.

    1. The EDMX file is out of sync with database.

    2. The database is not reachable (invalid connection string or the IIS pool user has no permission to access the database)

    3. Other issues.

     

    To figure out what other issue could be I would recommend to use WCF Diagnostics and WCF Trace tool.

    More about WCF tracing: http://developers.de/blogs/damir_dobric/archive/2009/03/24/using-of-wcf-trace.aspx and http://developers.de/blogs/damir_dobric/archive/2009/03/27/code-which-write-to-wcf-trace.aspx.

    For example you can find errors like this one: Parameter 'c' of method 'SomeCustomOperationInMyService' on type ' is of type ‘Contact' but a type assignable from ‘Customer' is required.

    Personally, I would like ADO.NET Data Services team to write out all error in the event log.Diagnostic tools helps a lot, but they are mostly more complex to use than Event Log. Such tools should be used to figure out real issues. But honestly, using of invalid connection string etc. in dev environment is such a trivial error which every admin should be able to fix, without of need to know anything about WCF and Service Model diagnostic.

  • WCF REST Messages with JSON and XML serializer

    Assume there is a service called AjaxService with following contract:

    image

    After starting of the service we would typically create the javascript proxy (helper class) of the REST service by invoking of following URL:

    http://myservicehost.myservice/ajaxproxy.svc/jsdebug

    The response shown in browser should be saved as for example myserviceproxy.js and imported as a javascript in your javascript application:

    <script src="ServiceProxies/AjaxServiceProxy.js" type="text/javascript"></script>

    Note that all three operations distinguish in style attributes.

    JSON in Body

    Operation DoWork is not a typical REST operation. But that operation is also not a typical SOAP operation. Input parameter will be transferred in the HTTP body in POST-method serialized as JSON (not by using of DataContractSerializer and XmlSerializer. Instead DataContractJsonSerializer will be used.).
    In other words the operation DoWork is implicitly styled with following attribute:

    [WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]

    To demonstrate what happen on the wire take a look on following javascript line of code, which invokes this operation:

    AjaxService.DoWork(m_Query.value, SucceededCallback, FailedCallback, "context");

    Request

    POST /DeclarativeServiceLibrary1/AjaxService.svc/DoWork HTTP/1.1
    Accept: */*
    Accept-Language: en-US,de-DE;q=0.9,bs-Cyrl;q=0.8,bs-Cyrl-BA;q=0.7,bs;q=0.6,bs-Latn;q=0.4,bs-Latn-BA;q=0.3,hr-HR;q=0.2,hr-BA;q=0.1
    Referer:
    http://localhost:29186/WidgetDemo/Go.htm
    Content-Type: application/json; charset=utf-8
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)
    Host: 192.168.3.8
    Content-Length: 17
    Connection: Keep-Alive
    Pragma: no-cache

    {"searchText":""}

     

    Response

    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Type: application/json; charset=utf-8
    Server: Microsoft-IIS/7.0
    X-AspNet-Version: 4.0.20604
    X-Powered-By: ASP.NET
    Date: Sat, 05 Sep 2009 20:54:25 GMT
    Content-Length: 535

    {"d":[{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 1","Key":"01","Price":1},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 2","Key":"02","Price":2},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 3","Key":"03","Price":3},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 7","Key":"04","Price":4},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 4","Key":"05","Price":5},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 5","Key":"06","Price":6}]}

     

    REST with JSON

    Operation DoRestWork is a REST operation (see attribute WebGet), because arguments will be transferred in request (simple args).

    AjaxService.DoRestWork(m_Query.value, SucceededCallback, FailedCallback, "context");

    Request

    GET /DeclarativeServiceLibrary1/AjaxService.svc/DoRestWork?searchText=%22%22 HTTP/1.1
    Accept: */*
    Accept-Language: en-US,de-DE;q=0.9,bs-Cyrl;q=0.8,bs-Cyrl-BA;q=0.7,bs;q=0.6,bs-Latn;q=0.4,bs-Latn-BA;q=0.3,hr-HR;q=0.2,hr-BA;q=0.1
    Referer:
    http://localhost:29186/WidgetDemo/Go.htm
    Content-Type: application/json; charset=utf-8
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)
    Host: 192.168.3.8
    Connection: Keep-Alive

    Response

    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Type: application/json; charset=utf-8
    Server: Microsoft-IIS/7.0
    X-AspNet-Version: 4.0.20604
    X-Powered-By: ASP.NET
    Date: Sat, 05 Sep 2009 20:56:01 GMT
    Content-Length: 535

    {"d":[{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 1","Key":"01","Price":1},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 2","Key":"02","Price":2},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 3","Key":"03","Price":3},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 7","Key":"04","Price":4},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 4","Key":"05","Price":5},{"__type":"MyEntity:http:\/\/daenet.eu","Description":"Product 5","Key":"06","Price":6}]}

    REST with XML

    Operation DoRestWorkXml is REST operation but response and request will be transferred as XML. Because i our example we use one input argument only searchTest, the argument will be transferred in request’s URI. Usually, more complicated entities would be transferred in the body in specified format.

    AjaxService.DoRestWorkXml(m_Query.value, SucceededCallback, FailedCallback, "context");

    Request

    GET /DeclarativeServiceLibrary1/AjaxService.svc/DoRestWorkXml?searchText=%22%22 HTTP/1.1
    Accept: */*
    Accept-Language: en-US,de-DE;q=0.9,bs-Cyrl;q=0.8,bs-Cyrl-BA;q=0.7,bs;q=0.6,bs-Latn;q=0.4,bs-Latn-BA;q=0.3,hr-HR;q=0.2,hr-BA;q=0.1
    Referer:
    http://localhost:29186/WidgetDemo/Go.htm
    Content-Type: application/json; charset=utf-8
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)
    Host: 192.168.3.8
    Connection: Keep-Alive

    Response

    HTTP/1.1 200 OK
    Cache-Control: private
    Content-Type: application/xml; charset=utf-8
    Server: Microsoft-IIS/7.0
    X-AspNet-Version: 4.0.20604
    X-Powered-By: ASP.NET
    Date: Sat, 05 Sep 2009 21:21:48 GMT
    Content-Length: 628

    <ArrayOfMyEntity xmlns="http://daenet.eu" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><MyEntity><Description>Product 1</Description><Key>01</Key><Price>1</Price></MyEntity><MyEntity><Description>Product 2</Description><Key>02</Key><Price>2</Price></MyEntity><MyEntity><Description>Product 3</Description><Key>03</Key><Price>3</Price></MyEntity><MyEntity><Description>Product 7</Description><Key>04</Key><Price>4</Price></MyEntity><MyEntity><Description>Product 4</Description><Key>05</Key><Price>5</Price></MyEntity><MyEntity><Description>Product 5</Description><Key>06</Key><Price>6</Price></MyEntity></ArrayOfMyEntity>

  • Mobility Day 2009

    Windows Mobile® 6.5 introduces the new internet capable application type. Typically WinMob 6.5 widgets are single-purpose applications which more or less display data obtained from the Internet. They are written using pure JavaScript code and bring the wealth of experience of Web developers to the Windows Mobile platform. Since widgets are installed executed locally on the mobile device, they provide ease of use and a better Internet user experience than conventional Web applications.
    In Mobility Day 2009 session sessionConsuming Services in Windows Mobile widgets” I will show how to build widget applications which consume REST and SOAP based services build on top WCF and JSON serialization technologies and run in new Application Server “Dublin”.

    This session is related to Dobrisa’s session “ Leverage Web Technologies to Build Experiences for Windows Mobile”. Dobrisa will show how more UI related widget staffs.

    Mobility Day

  • Hopper Test Tool for Windows Mobile 6.0, 6.1, and 6.5

    One mobile application must complete two hours of Microsoft’s Hopper test without exhibiting unpredictable behavior, hanging or crashing in order to be enabled for Mobile Marker Place.
    Hopper is a software test tool that simulates random user input on mobile devices. Required for certification for Windows Marketplace for Mobile.
    At this moment, there is a new version of Hopper for Windows Mobile 6.5 which also runs on Windows Mobile 6.0 and 6.1. The required Hopper version is 2.0.24.4074 or newer. The Hopper utility for Windows Mobile 6.0, 6.1 and 6.5 is available here.
    A focus application will also need to be customized and deployed to the device prior to running Hopper. This will ensure that Hopper's main focus is on the target application. More information on how to create a focus application is available here.

  • Silverlight 3 GDR2 Released

    Tody Microsoft has released a minor SIlverlight v3 release filed under “general distribution release 2”. Today, if your development environment is up to date, you will notice following line of code in the SL start page:

    <param name="minRuntimeVersion" value="3.0.40624.0" />

    This defines the minimal version of required Silverlight runtime. That means if we install the new higher one (compatible one) your existing applications should still work. The new version has been released today is versioned as 3.0.40818.0.

    The new runtime is compatible with GB18030 encoding standard. The standard, known as GB18030, replaces the existing Chinese standard GB2312/GBK. It's composary that all new products released in China after January 1, 2001 must support GB18030, which includes the existing GBK character set plus 6582 Unicode Extension-A, and 1,948 additional non-Han characters (Mongolian, Uygur, Tibetan, and Yi).

     

    So if your app targets Chinese “small” market, then you shoud ugrade. In this case you will have to set minor version as:

    <param name="minRuntimeVersion" value="3.0.40818.0" />

    This will cause your users to install the new SL runtime.

    For Developers

    All developers should install the new developer runtime (for Windows and/or Mac). Currently there are no new Tools updates.  There are just some minor updates in the SDK which aren’t required. But, if you want all latest staffs get them here.

  • Set of Technical Resources for Silverlight

    Get all that you need to keep you up to date on new releases, grow your skills, and tap into the leading RIA work from around the world.

    http://www.microsoft.com/silverlight/resources/technical-resources/#release-history

Copyright of SQL/Developers Community
Powered by Community Server (Commercial Edition), by Telligent Systems