I'm looking for a web service wrapper to convert my classes to web services. each class to a specific service and the type of instance management is "percall". are there any tools? Or are there any simple ways for this conversion?
for example this tool can add "service contract" attribute to classes and "operation contract" to public methods and also "data contract" to all inputs and output datas of public methods.
AFAIK that does not exist.
Web Services, with ASMX or WCF, are specific beasts. You cannot just take any class and make it a service. You need to define Data Contracts, Service Contract, an Operation Contract per method, etc.
Check out "Getting started with WCF" at http://msdn.microsoft.com/en-us/library/ms734712.aspx.
Good luck!
Related
We are developing a WCF service for internal company use. The entities (data contracts) are in a separate assembly and are referenced by both the service and applications that consume the service.
Is there any need to implement the IExtensibleDataObject interface?
No. IExtensibleDataObject (IEDO) is used if you expect your contract to receive (e.g., in a service call) more data than is listed in the data members. If you have the same assembly on both client and service this will not be the case.
For a more detailed description of the scenarios where IEDO is useful, check the post at http://blogs.msdn.com/b/carlosfigueira/archive/2011/09/27/wcf-extensibility-other-serialization-extensions.aspx.
I have a wcf service in 1 project and an object model that holds all my objects in another project. I add a reference to the object model in the service project and am able to use the objects in my service without incedent.
When I publish the service and other users use it. They are able to enter invalid data and schema and the service does Not fail.
I need the service to be connected to the object model. If users to not adhere to the schema of the objects the service should fail automatically.
Im am not sure if maybe I have to set a configuration maybe in the web.config?
What I am not understanding is if I set a property on an object to required. If the user does not add this property to the object being passed to the service why isnt the service automatically stopping?
[DataMember(IsRequired = true)]
public string VendorName { get; set; }
WCF automated approaches
To automate the WCF validation against its WSDL contract, you could use the WsdlExporter as shared in this MSDN blog.
WCF raw approaches
You could use a WCF schema validation behavior extension. The custom BehaviorExtension will allow you to enforce data validation of a defined schema.
You could also use a WCF parameter validation behavior extension to enforce parameter constraints.
See MSDN for WCF Input/Data Validation FAQ.
WCF Validation Commentary
Also review this great SO post regarding why WCF input/data validation isn't performed.
The Four Tenets of XML Messaging with WCF also provides an interesting perspective on Schema validation.
I wrote a couple of simple web methods (as a part of WCF service) that use a couple of (more complex) classes as input/returned parameters. Each web method attributed by [OperationContract], each data class attributed by [DataContract], each data field in the classes attributed by [DataMethod].
On the client side I can call these web methods by adding Service Reference.
All things are fine, but when I create an instance of some of the data classes above on client side, their constructors don't run.
Because it's a little complicate to initialize each instance, every time, I thought there is some way to initialize instances on client side by their own constructors.
Thanks in advance!
Ilan.
Methods exposed on data contracts (including constructors) in your service are only for service applications. Adding service reference will recreated only data structure of your data contract classes because service description is not able to describe logic and logic cannot be serialized.
All classes created with service reference are partial. You can create your own partial class and add your own custom constructors or you can share the assembly with data contracts between your service and client (but it will share all logic added to your data contract classes which is most often what you don't want). Sharing assembly will tightly couple your client and service.
I am not understanding how my model can be a WCF service. It makes sense when its an Astoria partial class residing on the client that allows remote calls to do persistence calls, but a WCF service doesn't have properties for model fields that can be used to update a data store.
Even if I could factor out an interface for a model/domain object class into a separate assembly, a silverlight project will not allow me to add that as a reference.
How should my ViewModel encompass my WCF calls? Ultimately the WCF will call a repository assembly implemented in Linq-to-Sql, but apparently those entities are not my model in this scenario, my WCF classes are?
Thanks for any guidance on this.
Also, posts I have read to give a frame of reference:
http://development-guides.silverbaylabs.org/Video/Silverlight-Prism#videolocation_0
http://blogs.conchango.com/davidwynne/archive/2008/12/15/silverlight-and-the-view-viewmodel-pattern.aspx
http://msdn.microsoft.com/en-us/magazine/dd458800.aspx
When you create a service reference to a WCF service in a Silverlight project it also generates an interface for that Service, this is similar to David Wynns IFeedService in the articles you listed above. The service reference will also generate proxy objects that represent the objects used by the service (Product, Category etc).
The important thing to note is that the service interface isn't the model, it's how you access the model. Going back to David's example, his ViewModel exposes a list of items (his model), this list is retrieved using the service.
If you're looking to share code between the client and server I'd reccomend looking into something like RIA Services. If this isn't for you then I'd look at a few articles around about sharing code between the server and client (via Add as Link).
Hope this helps
I want to know how the wsdl is written in wcf.
As i know the proxy class serialize the data and form a soap message to send over network, in the same way , i want to know who writes the wsdl file and takes care of serializing results of a call.
The abstract ServiceHostBase class has a method called CreateDescription that will take your service and operation contracts as well as your fault and data contracts and turns those into a ServiceDescription. This is then further handled by a WsdlExporter and turned into a WSDL and XSD file. What gets output to the WSDL (and XSD) is available on the service class as the "service description" (property "Description") - it contains information about the endpoints, bindings, other config settings etc.
Have a look at the MSDN Docs for the WsdlExporter class. You can even customize this process, if you want to - see these blog posts for more info on that:
Control generated WSDL from WCF Service
Flattening your WSDL
And have a look at the MSDN docs on:
Metadata Architecture Overview
Exporting custom metadata for a WCF extension
Marc