Platform Restful Web Services

In the release/source package from v1.52, there are test cases located at RapidWebDev.RestfulServices to show you how to call restful web services listed below by c# code basic HTTP GET/POST request.

Why Restful Web Services?

  • The web services are completely stateless. A good test is to consider whether the interaction can survive a restart of the server.
  • A caching infrastructure can be leveraged for performance. If the data that the web service returns is not dynamically generated and can be cached, then the caching infrastructure that web servers and other intermediaries inherently provide can be leveraged to improve performance. However, the developer must take care because such caches are limited to the HTTP GET method for most servers.
  • The service producer and service consumer have a mutual understanding of the context and content being passed along. Because there is no formal way to describe the web services interface, both parties must agree out of band on the schemas that describe the data being exchanged and on ways to process it meaningfully. In the real world, most commercial applications that expose services as RESTful implementations also distribute so-called value-added toolkits that describe the interfaces to developers in popular programming languages.
  • Bandwidth is particularly important and needs to be limited. REST is particularly useful for limited-profile devices such as PDAs and mobile phones, for which the overhead of headers and additional layers of SOAP elements on the XML payload must be restricted.
  • Web service delivery or aggregation into existing web sites can be enabled easily with a RESTful style. Developers can use technologies such as Asynchronous JavaScript with XML (AJAX) and toolkits such as Direct Web Remoting (DWR) to consume the services in their web applications. Rather than starting from scratch, services can be exposed with XML and consumed by HTML pages without significantly refactoring the existing web site architecture. Existing developers will be more productive because they are adding to something they are already familiar with, rather than having to start from scratch with new technology.

OrganizationService

Domain groups organization types with organizations. When you define a domain in RapidWebDev, you have to configure overall permission and sitemap sets for this domain. That means all users in the domain implicitly should work differently on some areas. Take our practice on developing an order application. We define three domains “Internal Organization”, “Customer” and “Vendor”. In “Internal Organization”, we have organization types as Sales Department, IT Department, Customer Service, Financial Department and Execute Management. We categorize customers into “VIP Customer”, “Enterprise Customer” and “Individual Customer” by organization types and categorize vendors into “CPU Product Vendor”, “Memory Product Vendor” etc. The internal organization users can manage customers, vendors, approve orders and so on depends on their permission. But internal users are impossible to “Confirm Money Accepted” for a vendor.

NameSpace : RapidWebDev.Platform.Services
Base Uri : http://Host : Port/Services/OrganizationService.svc

Method Name Http Method Uri Template Description
SaveOrganizationJson POST json/SaveOrganization Add/update organization object depends on whether identity of object is empty or not.
SaveOrganizationXml POST xml/SaveOrganization the same as above.
SaveOrganizationTypeJson POST json/SaveOrganizationType Add/Update organization type object.
SaveOrganizationTypeXml POST xml/SaveOrganizationType the same as above.
ListDomainsJson GET json/ListDomains Lists all available organization domains.
ListDomainsXml GET xml/ListDomains the same as above.
FindOrganizationTypesJson GET json/FindOrganizationTypes/{domain} Find organization types in specified domain.
FindOrganizationTypesXml GET xml/FindOrganizationTypes/{domain} the same as above.
GetOrganizationTypeByIdJson GET json/GetOrganizationTypeById/{organizationTypeId} Get the organization type by id.
GetOrganizationTypeByIdXml GET xml/GetOrganizationTypeById/{organizationTypeId} the same as above.
GetOrganizationTypeByNameJson GET json/GetOrganizationTypeByName/{organizationTypeName} Get the organization type by name.
GetOrganizationTypeByNameXml GET xml/GetOrganizationTypeByName/{organizationTypeName} the same as above.
GetOrganizationByIdJson GET json/GetOrganizationById/{organizationId} Get the organization by id.
GetOrganizationByIdXml GET xml/GetOrganizationById/{organizationId} the same as above.
GetOrganizationByCodeJson GET json/GetOrganizationByCode/{organizationCode} Get the organization by code.
GetOrganizationByCodeXml GET xml/GetOrganizationByCode/{organizationCode} the same as above.
GetOrganizationByNameJson GET json/GetOrganizationByName/{organizationName} Get the organization by name.
GetOrganizationByNameXml GET xml/GetOrganizationByName/{organizationName} the same as above.
BulkGetOrganizationsByIdsJson POST json/BulkGetOrganizationsByIds Find organizations by organization ids.
BulkGetOrganizationsByIdsXml POST xml/BulkGetOrganizationsByIds the same as above.
SearchJson GET json/search?domain={domain}&q={q}&start={start}&limit={limit}&sortfield={sortField}&sortDirection={sortDirection}&orgTypeId={orgTypeId} Search organizations by a collection of criterias for the authenticated user of request.
SearchXml GET xml/search?domain={domain}&q={q}&start={start}&limit={limit}&sortfield={sortField}&sortDirection={sortDirection}&orgTypeId={orgTypeId} the same as above.
QueryOrganizationsJson POST json/QueryOrganizations?pageindex={pageIndex}&pagesize={pageSize}&orderby={orderby} Query organizations by custom predicates.
QueryOrganizationsXml POST xml/QueryOrganizations?pageindex={pageIndex}&pagesize={pageSize}&orderby={orderby} the same as above.

RoleService

A role is associated with permissions. Besides, role can be associated with organization type that it allows to create different roles for each organization type. This enables the business requirement that administrator can assign user in different organization types with different role sets. Take an example. We have “Enterprise Customer” and “Individual Customer” in Customer domain. We may create roles “Enterprise Customer Administrators”, “Enterprise Customer Users” and “Enterprise Customer Managers” for “Enterprise Customer” but only “Individual Customer Users” for “Individual Customer”.

NameSpace : RapidWebDev.Platform.Services
Base Uri : http://Host : Port/Services/RoleService.svc

Method Name Http Method Uri Template Description
SaveJson POST json/Save Save role business object.It does create/update based on roleObject.Id. If id is empty, the method will create a new role object.If the specified id is invalid, the method will throw an exception.
SaveXml POST xml/Save the same as above.
HardDeleteJson GET json/HardDelete/{roleId} Delete role by id.
HardDeleteXml GET xml/HardDelete/{roleId} the same as above.
SetUserToRolesJson POST json/SetUserToRoles/{userId} Set user into roles which overwrites all existed roles of user.
SetUserToRolesXml POST xml/SetUserToRoles/{userId} the same as above.
GetByNameJson GET json/GetByName/{roleName} Get role id by role name.
GetByNameXml GET xml/GetByName/{roleName} the same as above.
GetByIdJson GET json/GetById/{roleId} Get role by role id.
GetByIdXml GET xml/GetById/{roleId} the same as above.
BulkGetJson POST json/BulkGet Bulkget role objects by a collection of role ids.
BulkGetXml POST xml/BulkGet the same as above.
FindAllJson GET json/FindAll Find all available roles.
FindAllXml GET xml/FindAll the same as above.
FindByOrganizationIdJson GET json/FindByOrganizationId/{organizationId} Get all roles associated to the specified organization.
FindByOrganizationIdXml GET xml/FindByOrganizationId/{organizationId} the same as above.
FindByUserIdJson GET json/FindByUserId/{userId} Find all roles of specified user.
FindByUserIdXml GET xml/FindByUserId/{userId} the same as above.
FindByOrganizationTypeJson GET json/FindByOrganizationType/{organizationTypeId} Find roles by organization type id.
FindByOrganizationTypeXml GET xml/FindByOrganizationType/{organizationTypeId} the same as above.
IsUserInRoleByIdJson GET json/IsUserInRoleById/{userId}/{roleId} Gets true if specified user is in role.
IsUserInRoleByIdXml GET xml/IsUserInRoleById/{userId}/{roleId} the same as above.
IsUserInRoleByNameJson GET json/IsUserInRoleByName/{userId}/{roleName} Gets true if specified user is in role.
IsUserInRoleByNameXml GET xml/IsUserInRoleByName/{userId}/{roleName} the same as above.
QueryRolesJson POST json/QueryRoles?pageindex={pageIndex}&pagesize={pageSize}&orderby={orderby} Find role objects by custom predicates.
QueryRolesXml POST xml/QueryRoles?pageindex={pageIndex}&pagesize={pageSize}&orderby={orderby} the same as above.

MembershipService

A user can be assigned with multiple roles that the user inherits the permissions of these roles. And a user can be set permission explicitly. That means, the permissions owned by a user depends on both explicit permissions and permissions of roles. In RapidWebDev, a user has to belong to an organization. But in a simple application development, what we can do if we don’t need concept “organization”? In this case, you can work around by creating a default organization and making all users belong to it.

NameSpace : RapidWebDev.Platform.Services
Base Uri : http://Host : Port/Services/MembershipService.svc

Method Name Http Method Uri Template Description
SaveJson POST json/Save Add/update user object depends on whether identity of object is empty or not.
SaveXml POST xml/Save the same as above.
BulkGetJson POST json/BulkGet Resolve user objects from enumerable user ids.
BulkGetXml POST xml/BulkGet the same as above.
GetByNameJson GET json/GetByName/{userName} Get user by user name.
GetByNameXml GET xml/GetByName/{userName} the same as above.
GetByIdJson GET json/GetById/{userId} Get user object by user id.
GetByIdXml GET xml/GetById/{userId} the same as above.
ChangePasswordJson POST json/ChangePassword/{userId} Change password of specified user.
ChangePasswordXml POST xml/ChangePassword/{userId} the same as above.
QueryUsersJson POST json/QueryUsers?pageindex={pageIndex}&pagesize={pageSize}&orderby={orderby} Find user business objects by custom predicates.
QueryUsersXml POST xml/QueryUsers?pageindex={pageIndex}&pagesize={pageSize}&orderby={orderby} the same as above.

PermissionService

NameSpace : RapidWebDev.Platform.Services
Base Uri : http://Host : Port/Services/PermissionService.svc

Method Name Http Method Uri Template Description
SetRolePermissionsByJson POST json/SetRolePermission/{roleId} Set permissions on specified role. The new permissions will overwrite the existed permissions of the role.
SetRolePermissionsByXml POST xml/SetRolePermission/{roleId} the same as above.
SetUserPermissionsByJson POST json/SetUserPermission/{userId} Set permissions on specified user. The new permissions will overwrite the existed permissions of the user.
SetUserPermissionsByxml POST xml/SetUserPermission/{userId} the same as above.
FindUserPermissionsByJson GET json/FindUserPermissions/{userId}/{explicitOnly} Get permissions which the user has.
FindUserPermissionsByXml GET xml/FindUserPermissions/{userId}/{explicitOnly} the same as above.
FindRolePermissionsByJson GET json/FindRolePermissions/{roleId} Get permissions which the role has.
FindRolePermissionsByXml GET xml/FindRolePermissions/{roleId} the same as above.
DoesTheUserHasPermissionJson GET json/HasPermission/{userId}/{permissionValue} Returns true if input user has the permission.The permissions owned by the user includes the ones inherited from the roles of the user implicitly.
DoesTheUserHasPermissionXml GET xml/FindOrganizationTypes/{domain} the same as above.
DoesTheCurrentUserHavePermissionJson GET json/HasPermission/{permissionValue} Returns true if the current authenticated user has any permissions in specified permission
DoesTheCurrentUserHavePermissionXml GET xml/HasPermission/{permissionValue} the same as above.

ConcreteDataService

Concrete data provides model and API for developers to easily manage enumerable data without writing much code.
Take an example. A product has properties Size and Dimension in product management system. Size and Dimension are not free input but user only needs to select from a dropdown. The options of the dropdown are maintained by administrators. In this case, you only need to define two concrete data type in platform configuration. RapidWebDev provides you the UI and API to CRUD concrete data in these types intelligently.

NameSpace : RapidWebDev.Platform.Services
Base Uri : http://Host : Port/Services/ConcreteDataService.svc

Method Name Http Method Uri Template Description
SaveJson POST json/Save Add/update concrete data object depends on whether identity of object is empty or not.
SaveXml POST xml/Save the same as above.
GetByIdJson GET json/GetById/{concreteDataId} Get an non-deleted concrete data by id.
GetByIdXml GET xml/GetById/{concreteDataId} the same as above.
GetByNameJson GET json/GetByName/{type}/{name} Get an non-deleted concrete data by name.
GetByNameXml GET xml/GetByName/{type}/{name} the same as above.
FindByKeywordJson GET json/FindByKeyword?concreteDataType={concreteDataType}&q={query}&limit={limit} Find non-deleted concrete data by a keyword which may be included in concrete data name or value.
FindByKeywordXml GET xml/FindByKeyword?concreteDataType={concreteDataType}&q={query}&limit={limit} the same as above.
FindConcreteDataTypesJson GET json/FindConcreteDataTypes Find all available concrete data types.
FindConcreteDataTypesXml GET xml/FindConcreteDataTypes the same as above.
QueryConcreteDataJson POST json/QueryConcreteData?pageindex={pageIndex}&pagesize={pageSize}&orderby={orderby} Find concrete data in all types by custom predicates.
QueryConcreteDataXml POST xml/QueryConcreteData?pageindex={pageIndex}&pagesize={pageSize}&orderby={orderby} the same as above.


HierarchyService

Hierarchy API allows you to create any data in hierarchy like Geography and Position. If your system needs two types of data in hierarchy, Geography and Position, you need to setup these hierarchy types first. Then create hierarchy data into each type.

NameSpace : RapidWebDev.Platform.Services
Base Uri: http://Host : Port/Services/HierarchyService.svc

Method Name Http Method Uri Template Description
SaveJson POST json/Save Add/update hierarchy data object depends on whether identity of object is empty or not.
SaveXml POST xml/Save the same as above.
GetHierarchyDataByIdJson GET json/GetHierarchyDataById/{hierarchyDataId} Get an non-deleted hierarchy data by id.
GetHierarchyDataByIdXml GET xml/GetHierarchyDataById/{hierarchyDataId} the same as above.
GetHierarchyDataByNameJson GET json/GetHierarchyDataByName/{hierarchyType}/{hierarchyDataName} Get an non-deleted hierarchy data by name.
GetHierarchyDataByNameXml GET xml/GetHierarchyDataByName/{hierarchyType}/{hierarchyDataName} the same as above.
GetImmediateChildrenJson GET json/GetImmediateChildren/{hierarchyType}/{parentHierarchyDataId} Get all children of the specified hierarchy data by id.
GetImmediateChildrenXml GET xml/GetImmediateChildrenJson/{hierarchyType}/{parentHierarchyDataId} the same as above.
GetAllChildrenJson GET json/GetAllChildren/{hierarchyType}/{parentHierarchyDataId} Get all children of the specified hierarchy data includes not immediately.
GetAllChildrenXml GET xml/GetAllChildren/{hierarchyType}/{parentHierarchyDataId} the same as above.
GetAllHierarchyDataJson GET json/GetAllHierarchyDataJson/{hierarchyType} Get all hierarchy data in specified hierarchy type.
GetAllHierarchyDataXml GET xml/GetAllHierarchyDataJson/{hierarchyType} the same as above.
HardDeleteHierarchyDataJson GET json/HardDeleteHierarchyData/{hierarchyDataId} Hard delete a hierarchy data with all its children by id.
HardDeleteHierarchyDataXml GET xml/HardDeleteHierarchyData/{hierarchyDataId} the same as above.
FindByKeywordJson GET json/FindByKeyword?hierarchyType={hierarchyType}&q={query}&limit={maxReturnedCount} Find all hierarchies which include the query keyword in code or name.
FindByKeywordXml GET xml/FindByKeyword?hierarchyType={hierarchyType}&q={query}&limit={maxReturnedCount} the same as above.
QueryHierarchyDataJson POST json/QueryHierarchyData?pageIndex={pageIndex}&pageSize={pageSize}&orderby={orderby} Find hierarchy data in all types by custom predicates.
QueryHierarchyDataXml POST xml/QueryHierarchyData?pageIndex={pageIndex}&pageSize={pageSize}&orderby={orderby} the same as above.

RelationshipService

Relationship is used for developers to setup One2One, One2Many and Many2Many relationship between two objects by ID without refactoring data table but through API only. Relationship API reduces the work that developer has to refactor data tables for any data relationship and it obviously cuts down the complexity and workload of system development.

NameSpace : RapidWebDev.Platform.Services
Base Uri : http://Host : Port/Services/RelationshipService.svc

Method Name Http Method Uri Template Description
SaveJson GET json/Save?objectXId={objectXId}&objectYId={objectYId}&RelationshipType={RelationshipType}&Ordinal={Ordinal} Set permissions on specified role. The new permissions will overwrite the existed permissions of the role.
SaveXml GET xml/Save?objectXId={objectXId}&objectYId={objectYId}&RelationshipType={RelationshipType}&Ordinal={Ordinal} the same as above.
RemoveJson GET json/Remove?objectXId={objectXId}&objectYId={objectYId}&relationshipType={relationshipType} Remove the relationship b/w X and Y in the special relationship type.
RemoveXml GET xml/Remove?objectXId={objectXId}&objectYId={objectYId}&relationshipType={relationshipType} the same as above.
GetOneToOneJson GET json/GetOneToOneJson/{objectId}/{relationshipType} Get the object related to the target object in special type.
GetOneToOneXml GET xml/GetOneToOneJson/{objectId}/{relationshipType} the same as above.
GetManyToOneJson GET json/GetManyToOne/{objectId}/{relationshipType} Get the object related to the target object in special type.
GetManyToOneXml GET xml/GetManyToOne/{objectId}/{relationshipType} the same as above.
GetOneToManyJson GET json/GetOneToMany/{objectId}/{relationshipType} Get the object related to the target object in special type.
GetOneToManyXml GET xml/GetOneToMany/{objectId}/{relationshipType} the same as above.
FindAllRelationshipJson GET json/FindAllRelationship/{objectId} Find all objects related to the target object in any special relationship type.
FindAllRelationshipXml GET xml/FindAllRelationship/{objectId} the same as above.

SequenceService

Sequence Number is used to generate sequence number without writing code just calling API, like Order Number and Product Number.

NameSpace : RapidWebDev.Platform.Services
Base Uri :http://Host : Port/Services/SequenceService.svc

Method Name Http Method Uri Template Description
CreateSingleJson GET json/CreateSingle?objectId={objectId}&sequenceNoType={sequenceNoType} Create sequence number on specified type for special object id. The method generates the sequence number suppressing transaction scope which means the generated sequence number cannot be rollback.
CreateSingleXml GET xml/CreateSingle?objectId={objectId}&sequenceNoType={sequenceNoType} the same as above.
CreateMultipleJson GET json/CreateMultiple?objectId={objectId}&sequenceNoType={sequenceNoType}&sequenceNoCount={sequenceNoCount} Create sequence numbers on specified sequence number type.The method generates the sequence number suppressing transaction scope which means the generated sequence number cannot be rollback.
CreateMultipleXml GET xml/CreateMultiple?objectId={objectId}&sequenceNoType={sequenceNoType}&sequenceNoCount={sequenceNoCount} the same as above.

Last edited Mar 25, 2010 at 3:03 AM by TimYi, version 10

Comments

No comments yet.