Using URL redirect instead of input param for WCF service

时光总嘲笑我的痴心妄想 提交于 2019-12-13 03:34:30

问题


While investigating the Organization.svc in Dynamics CRM, I found that it is using URL redirect for changing the Organizations. That means for each Organization it simulate URL to access Organization.svc.

There is just one SVC file but multiple URLs to access it e.g. Organization Org1 will have URL http://CRMserver_name/Org1/XRMServices/2011/Organization.svc and Org2 will have http://CRMserver_name/Org2/XRMServices/2011/Organization.svc

I was wondering if there is any benefits for doing this as compare to passing input param to SVC. Please share your thoughts on the pros and cons for these two things.


回答1:


I learned something new today. Pardon me if you know this already.

There are two different things –

  1. URL routing - http://msdn.microsoft.com/en-us/library/ee358760.aspx
  2. URL rewrite - http://msdn.microsoft.com/en-us/library/ms972974.aspx

URL routing is ultimate thing. It is totally virtual and no need to register routes in IIS. So now I know why Dynamics CRM is using it. Using routing client doesn’t need to specify Organization name for each method call of WCF service. While creating client object, URL itself gives that info. Client only needs to do this once and all methods are now aware of Organization name for particular WCF call.

This example can help get you started with URL routing for WCF - http://msdn.microsoft.com/en-us/library/ee662952.aspx

Hope this helps someone! -Nilesh




回答2:


My guess would be cleaner URLs and also it follows a sort of conventions for Dynamics CRM. As far as I can tell, URLs have always been in the format http://CRMserver_name/OrgName/...



来源:https://stackoverflow.com/questions/6776172/using-url-redirect-instead-of-input-param-for-wcf-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!