I want to delete some specific lines from my web.config while copying the file to the artifact using azure yaml pipelines.
Actual:
`<service behaviorConfiguration="mybehavior" name="">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract=""/>
<!--<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>-->
</service>
<service behaviorConfiguration="mybehavior" name="">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract=""/>
<!--<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>-->
</service>`
Expected: delete lines with comments
`<service behaviorConfiguration="mybehavior" name="">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract=""/>
</service>
<service behaviorConfiguration="mybehavior" name="">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="" contract=""/>
</service>`
For information, I have the following task (CopyFile#2) in my current yml pipelines:
`- task: CopyFiles#2
displayName: Copy web config into the Package
condition: eq(variables.generateConfigs, true)
inputs:
SourceFolder: '$(ReleasesPath.SourceFolderName)'
Contents: |
Web.config
TargetFolder: '$(CopyPath.TragetFolderName)'
CleanTargetFolder: false
preserveTimestamp: true`
Related
I have a problem. I try to build a WCF Communication with multiple entpoints. But it never works and it displays a ErrorMessage like this:
The contract name '{0}' could not be found in the list of contracts implemented by the service '{1}'.
And this is my Config-File:
*
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="MwWcfLibrary.Service">
<endpoint address="net.tcp://localhost:8733"
binding="netTcpBinding"
bindingConfiguration=""
bindingName="Action"
name="ActionInterface"
contract="MwWcfLibrary.Actions.Interfaces.IAction">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexTcpBinding"
bindingConfiguration=""
name="Mex"
contract="IMetadataExchange" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint binding="netTcpBinding"
address="net.tcp://localhost:8733"
bindingConfiguration=""
name="LifeSignInterface"
bindingName="LifeSign"
contract="MwWcfLibrary.LifeSign.Interfaces.ILifeSign" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint binding="netTcpBinding"
address="net.tcp://localhost:8733"
bindingConfiguration=""
name="DataInterface"
bindingName="Data"
contract="MwWcfLibrary.Notification.Interfaces.IData">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint binding="netTcpBinding"
address="net.tcp://localhost:8733"
bindingConfiguration=""
name="PublicDataInterface"
bindingName="PublicData"
contract="MwWcfLibrary.PublicData.Interfaces.IPublicData" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint binding="netTcpBinding"
address="net.tcp://localhost:8733"
bindingConfiguration=""
name="PublicStateInterface"
bindingName="PublicState"
contract="MwWcfLibrary.PublicState.Interfaces.IPublicState" >
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8733//MwWcfLibrary" />
</baseAddresses>
<timeouts closeTimeout="00:00:30" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
*
Does someone figure out if i configured something wrong?
Kind Regards.
EDIT
You either haven't implemented one of these interfaces:
MwWcfLibrary.Actions.Interfaces.IAction, MwWcfLibrary.LifeSign.Interfaces.ILifeSign, MwWcfLibrary.PublicData.Interfaces.IPublicData and MwWcfLibrary.PublicState.Interfaces.IPublicState
or one or more of them is not decorated with the [ServiceContract] attribute
Include the actual error in your question instead of '{0}', you'll see that some of your contracts have not been implemented by the class Service which should look like this (at least):
class Service : IAction, ILifeSign, IPublicData, IPublicState
{
// implementation
}
Also, your address attributes don't appear to be correct, since you've defined a base address ending with a segment //Mww... yet in your endpoints the address is shorter than the base address. The endpoint addresses can just be relative like "Service".
Previously
The Service element refers to a class that's an implementation of a ServiceContract interface, which is what goes into the endpoint contract attribute. Verify the fully qualified names of your interfaces and classes in theses attributes.
From looking at your configuration file, you are saying that the class MwWcfLibrary.Service implements the ([ServiceContract] decorated) interfaces called MwWcfLibrary.Actions.Interfaces.IAction, MwWcfLibrary.LifeSign.Interfaces.ILifeSign, MwWcfLibrary.PublicData.Interfaces.IPublicData and MwWcfLibrary.PublicState.Interfaces.IPublicState
That seems to be in error. Do you mean to have two services, each with a separate endpoint?
I have a wcf service and used a console app as the host for my service. when I use base address like this: <baseaddres ="http://ipaddress:8080/" />. When I check my service operation through a web browser I can open the service WSDL and it works fine.
But, as I change the port number to something else. The service host starts fine (with no exception of used port number or anything else). As I go to check if the service is running through web browser the service is not shown. eventually my client also could not locate the service.
app.config configuration
<services>
<service name="Natatorium_WCF.NatatoriumService"
behaviorConfiguration="ServiceBehavior">
<endpoint address="NatatoriumService"
binding="wsHttpBinding"
contract="Natatorium_WCF.INatatoriumService"
bindingConfiguration="wsHttpBindingConfig">
</endpoint>
<endpoint address="NatatoriumService"
binding="netTcpBinding"
contract="Natatorium_WCF.INatatoriumService"
bindingConfiguration="netTcpBindingConfig" >
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://[ServerName]:[PortNO.1]"/>
<add baseAddress="net.tcp://[ServerName]:[PortNO.2]"/>
</baseAddresses>
</host>
</service>
</services>
this is the host code to start the service (console application).
static void Main(string[] args)
{
ChangeServerConfigFileAttributeValue("8080", "8090");
using (ServiceHost host = new ServiceHost(typeof(Natatorium_WCF.NatatoriumService)))
{
host.Open();
Console.WriteLine("Listening...");
Console.ReadLine();
}
}
<configuration>
<system.serviceModel>
<services>
<service name="HelloService.HelloService" behaviorConfiguration="mexBehaviour">
<endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService" ></endpoint>
<endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService" ></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" ></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
<add baseAddress="net.tcp://localhost:8090/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<remove name="serviceDebug"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
I have a WCF service that has one http endpoint,
I would like to add another http endpoint address with a different binding.
The service is not hosted in IIS and hence setting the multipleSiteBindingsEnabled
is of no use.
Am trying something like this.
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="ServiceBehaviorConfiguration"
name="ServerService">
<endpoint address="http://localhost:6732/ServerService" binding="webHttpBinding" behaviorConfiguration="webby"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://localhost:800/ServerService" binding="basicHttpBinding"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:800/ServerService" />
<add baseAddress="http://localhost:6732/ServerService" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
Try something like the config shown below. It exposes multiple endpoints through a single port but I'm sure this pattern of configuration is supported by WCF.
<services>
<service behaviorConfiguration="ServiceBehaviorConfiguration"
name="ServerService">
<endpoint address=""
binding="webHttpBinding"
behaviorConfiguration="webby"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="basic"
binding="basicHttpBinding"
contract="IClientAppContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:800/ServerService" />
</baseAddresses>
</host>
</service>
</services>
You could create two services that each have their own different baseAddress, but their internal endpoints are identical.
<services>
<service name="WebServices.Service" behaviorConfiguration="WebServices.ServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="http://ip/Service.svc" binding="wsHttpBinding" contract="WebServices.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
but my endpoint is still
svcutil.exe http://server-iis/Service.svc?wsdl. How to change server-iis to my IP?
Try solution suggested in here.
I'am not sure but I hope this suggestion helps you.
I created a service which allows clients to search for user information. This is exposed as an interface ISearchUsers.
I used this article as a base but to no avail: Not sure if this is the way to go
link text
Now I want to create and expose an interface called ICreateUser and i assumed that i had to create a new endpoint , basicHttp binding and used the article above.
This is part of my config:
<services>
<service behaviorConfiguration="Service.Service1Behavior"
name="Service.SearchService">
<clear />
<endpoint binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding"
contract="Service.ISearchService" listenUriMode="Explicit">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
listenUriMode="Explicit">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Service/Service1/" />
</baseAddresses>
</host>
</service>
</services>
You can extend your current service class which implements ISearchUser and let it implement ICreateUser as well - in that case, you could add a second endpoint to your service config:
<services>
<service name="Service.SearchService"
behaviorConfiguration="Service.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Services/" />
</baseAddresses>
</host>
<endpoint
address="SearchUser"
binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding"
contract="Service.ISearchService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="CreateUser"
binding="basicHttpBinding" bindingConfiguration="WsHttpMtomBinding"
contract="Service.ICreateUserService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
One thing that most likely doesn't work in your case is the fact you pick "basicHttpBinding" as your binding, but the bindingConfiguration seems to indicate WsHttpBidning..... those need to match and thus should probably be:
<endpoint
address="CreateUser"
binding="basicHttpBinding" bindingConfiguration="basicHttpMtomBinding"
contract="Service.ICreateUserService">
Marc