开发者

Generating or Updating OperationContract on the fly

Is there a way to generate or update an OperationContract on the fly?

So for example:

  1. The user will click a button on a control panel screen.
  2. The web service or the WCF service will get updated with a new function.
  3. The other users can then consume the new function from anywhere.

I have seen that in action, however, I am not sure how to achieve that, I am only be able to create or generate OperationContract while I am on Visual Studio, but not on the fly while the service has already been h开发者_JS百科osted.

Please help.

Many Thanks


You can use System.Reflection to build assemblies on the fly. Check this link:

http://www.williamb.net/defining-and-hosting-wcf-service-contracts-at-runtime


This is not possible for SOAP services. SOAP services define contract which is exposed as WSDL. Once you modify the service you must let your client know about changes because client must know that there is new operation and probably new transfered data. Reflection is not an option because client usually doesn't have access to assembly created by service => client can't be notified about new operation and new data which must be serialized and deserialized.

This can be done with REST services because in REST service you are defining resources which are accessible by its URI and HTTP method. But again you must notify the client that new resource is available. This is usually achieved by browsing resources. You have top level resource which contains information about other resources and their URIs. You will just add URI of the new resource into main resource. Current version of WCF makes this approach very complicated because you think in terms of resources but still have to work in terms of operations.

I still don't understand why people still try to build dynamic applications this way. Pushing button and adding new method will be so complicated. Perhaps if you modify your question and explain what you want to do, you will get better ideas how to achieve that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜