Ignacio Soler Garcia
Ignacio Soler Garcia

Reputation: 21855

I get an error using svcutil to generate the WCF client of a Named Pipe service hosted using ServiceHost

I am using the following command:

svcutil.exe /language:c# /out:agnServiceClient.cs /config:app.config net.pipe://localhost/agnService

And I'm getting the following ProtocolException on the server:

Stream Security is required at http://www.w3.org/2005/08/addressing/anonymous, but no security context was negotiated. This is likely caused by the remote endpoint missing a StreamSecurityBindingElement from its binding.

The server is configured as follows:

<system.serviceModel>
    <bindings>
        <netNamedPipeBinding>
            <binding name="NetNamedPipeBinding_IWordDuplexCommunicationService" closeTimeout="00:01:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:30:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="204003200" maxConnections="10" maxBufferSize="204003200" maxReceivedMessageSize="204003200">
                <readerQuotas maxDepth="204003200" maxStringContentLength="204003200" maxArrayLength="204003200" maxBytesPerRead="204003200" maxNameTableCharCount="204003200" />
                <security mode="Transport">
                    <transport protectionLevel="EncryptAndSign" />
                </security>
            </binding>
        </netNamedPipeBinding>
    </bindings>
    <extensions>
        <behaviorExtensions>
            <add name="sessionToken" type="Agn.Infrastructure.Security.Session.JSessionBehaviorElement, Agn.Infrastructure.Security" />
        </behaviorExtensions>
    </extensions>
    <behaviors>
        <serviceBehaviors>
            <behavior name="returnFaults">
                <serviceDebug includeExceptionDetailInFaults="true" />
                <serviceMetadata httpGetEnabled="false" />
                <dataContractSerializer maxItemsInObjectGraph="204003200" />
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="sessionToken">
                <sessionToken />
            </behavior>
        </endpointBehaviors>
    </behaviors>
    <services>
        <service name="Agn.Shell.Services.AgnService">
            <endpoint address="net.pipe://localhost/agnService" binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IWordDuplexCommunicationService" contract="Agn.Shell.Services.IAgnService"  />
        </service>
    </services>

And the code is as simple as this:

[ServiceContract]
public interface IAgnService
{
    [OperationContract]
    PageWrapper<Callejero> GetListCallejero(FiltroCallejero filter, PageWrapper page);
}

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single, MaxItemsInObjectGraph = WellKnownGeneralConstants.ImagnaMaxItemsInObjectGraph)]
public class AgnService : IAgnService
{
    private readonly ICallejeroService callejeroService;

    public AgnService(ICallejeroService callejeroService)
    {
        this.callejeroService = callejeroService;
    }

    public PageWrapper<Callejero> GetListCallejero(FiltroCallejero filter, PageWrapper page)
    {
        return this.callejeroService.GetList(filter, page) as PageWrapper<Callejero>;
    }
}

The startup code:

public void StartupService()
{
    this.agnServiceHost = new ServiceHost(this.Container.Resolve<IAgnService>());
    this.agnServiceHost.Open();
}

Any hint?

Upvotes: 0

Views: 303

Answers (0)

Related Questions