Xomega provides a way to specify one or more endpoint configuration templates for your WCF services and then generate the initial client-side or server-side set up for each of the services defined in your Xomega service model. If you include such generation into the build of the Xomega model then it will help you automatically take care of updating the service configurations whenever you add new services. Once added, the endpoints will not be modified during subsequent regeneration, which allows you to customize them without fearing of losing your changes.
The steps to set up endpoint configuration templates are as following.
- Open the global configuration file for your model, which contains config element as the root. If you don't have such file, add one to the Xomega project by clicking the Add New Item menu on the project and selecting the Xomega Model Configuration template.
- Add or locate the wcf:services element inside the global config element, where the wcf prefix should be mapped to the "http://www.xomega.net/wcf" namespace, and configure the namespace for the generated services.
- For each type of binding that your WCF services will support, add a corresponding wcf:endpoint element inside of the wcf:services element.
- Set the binding attribute to a standard or custom WCF binding name.
- Set the baseLocalAddress attribute to the base URL of the server-side endpoints for this binding. It should include the protocol and the port number and end with a slash. The service name will be appended to it for each individual endpoint. For local development, when both the services and the client are running on the same machine, it can also be used for the client-side configuration.
- If the client and the services will be running on different machines, then set the remoteLocalAddress attribute to specify the base URL of the server to be accessed by the client.
- If you have configurations for multiple bindings, then set the namePrefix attribute to allow generating a unique endpoint name for each binding.
Below is a sample configuration that demonstrates these steps.
Code:
<config xmlns="http://www.xomega.net/omodel"
xmlns:wcf="http://www.xomega.net/wcf">
<wcf:services namespace="MyProject.Services" implNamespace="MyProject.Entities.Services">
<wcf:endpoint binding="netTcpBinding" baseLocalAddress="net.tcp://localhost:8008/"
baseRemoteAddress="net.tcp://remotehost:8008/" namePrefix="tcp"/>
<wcf:endpoint binding="wsHttpBinding" baseLocalAddress="http://localhost:8080/" namePrefix="http"/>
</wcf:services>
</config>
To generate server/client WCF service configuration perform the following steps.
- Open the properties of the WCF Server Configuration or the WCF Client Configuration in the Service Layer generator group.
- Set the Output Path to the server-side or the client-side configuration file.
- For the server configuration you can also specify the Endpoint Behavior and the Service Behavior that would be used by each generated endpoint and service respectively.
- Run the generator and review the generated endpoints in the output file. If you need to make a change in the model configuration and regenerate, then you need to manually delete the generated endpoints first.