Creating guidance Package WCF Web Service
- Creating Guidance Service Factory Model Project
- Creating Service Contract Model
- Creating XML Schemas for Service Contract
- Creating Data Contract Model
- Creating WCF WebService
- Creating Host Model
Steps1
Create new project in VS2008
In Guidance PackagesSelect Service Factory
Click on OK
Right click on ExampleServiceService Factory Modeling Edition
- Add new ServiceContract model
Give model name: ExampleServicecontract
XML Namespace:
Click on Finish
From toolbox
- drag two XSD Message
- Click on left side XSD Message Box and press F4 for properties
- In a property change Is WrappedFalls to True
- Change Name to ExmpDataServiceRequest
- Change name for right side XSD Message Box as ExmpDataServiceResponse and alsoIs WrappedFalls to True
- Add one Operation change name as GetExampleDataOperationby pressing F4 or Click on the name
- Right click on Faults and add new data contract fault change the name as ExampleFaultMessage
- Same as above how you are adding XSD Message Box (XML Schema) & Operations, like that you have to add
- ServiceContract change name as ExampleDataServiceContract
- Service change name as ExampleDataService
- Now you complete Half of Service Contract Design
- Click on Connector
- Come on the design drag from Request XSD file (left side) to Operation
- then Operation to Response XSD
- Operation to Service Contract
- Service Contract to Service
Adding XML Schemas for XSD Message files
- Add two XML Schemas because you added two XSD Message
- Always Left XSD Message is Request and Right is Response
- You have to give a name for two XML Schemas such a way that you can identify which schema is for which XSD Message
Example
XSD MessageXML Schema
AbcDataTransferRequestDataTransferRequest
WiproFacilityUsageRequestFacilityUsageRequest
Like this you can make out this XML for This XSD
- Change both the schema name as
- DataServiceRequest
- DataServiceResponse
In each xml file you add
xs:elementname="FacilityMgmtRequest"
<xs:complexType
<xs:sequence
<xs:elementname="facilityusage"
<xs:complexType
<xs:sequencemaxOccurs="unbounded"
<xs:elementname="datarow"
<xs:complexType
<xs:sequence
<xs:elementname="FacilityID"type="xs:integer"</xs:element
<xs:elementname="Name"type="xs:string"</xs:element
<xs:elementname="LocationID"type="xs:integer"</xs:element
</xs:sequence
</xs:complexType
</xs:element
</xs:sequence
</xs:complexType
</xs:element
</xs:sequence
</xs:complexType
</xs:element
- now you come to ServiceContract design and select Request XSD Message got to propertiy and click on element
- select request element from request XML Schema
- do same for response also
if get no element found
Then go to respected XML Schema delete
xmlns:mstns="
then try you will get element after that undo the deleted one.
below image for request XSD Message do same for Response XSD
Adding new Data Contract
Model Name: ExampleDataContract
XML Namespace:
- Add One Fault Contract
- Change name as ExampleFaultContract
- Add one primitive data type in members
- Change name as ExampleFaultMessage
Creating WCF WebService
On Solution Explorer add new WCF Implementation Projects
New of WCF web service name is ExampleWCFService
It will generate automatic code for all like
- Business Logic (Folder)
- BusinessEntities
- BusinessLogic
- Resource Access(Folder)
- DataAcess
- ServiceInterface (Folder)
- DataContracts
- FaultContracts
- MessageContracts
- ServiceContracts
- ServiceImplementation
- Test(Folder)
- Host
- Client
Setting some properties in DataContract Design ServiceContract Design Pages
1.Come to DataContract Design Page Press F4 you will get
Select Implementation Technology is WCF Extension
Project Mapping Table is ExampleWCFService
Right click on DataContract Design Page and click on Validate
You shouldn’t get any error
If you don’t get any error go a head with generate code by pressing right click on design page
2.
Select Type by press F4 on ExampleFaultMessage in ServiceContract Design Page
3. Come to serviceContract Design Page press F4 you will get
Select Implementation Technology is WCF Extension
Project Mapping Table is ExampleWCFService
Right click on the ServiceContract Design page and click on Validate All
You shouldn’t get any error
Rebuild your Service Solution
Settings in Host
Double Click on Examplehost
You will find Host Model Explore on right side
Right click on the Host Model and Add New Host Application
You will get HostApplication1 Goto Properties of it and change
- Implementation Project
- Implementation Technology as WCF
- Change Name as ExampleHost
Right Click on the host add new Service Reference
Go to Property of the ServiceReference1
- change Enable Metadata Publish False to True
- Change name as ExampleService
- Select the Service Implementation
Adding New EndPoint to Host Model
Change the name of Endpoint1 to ExampleEndpoint
Right click on ExampleEndpoint and select ValidateAll
Click on ExampleService you will see like this and click on Generate Code
This is the End of All type of setting on Design
Lets Start with Coding in Service and interact with application