How to Enable GZip Compression when Communicating with a Remote Service Using WSDL and WCF - wcf

I'm trying to send data to the IRS using a WSDL file and WCF. I'm using .NET and Microsoft VS.NET, which created a proxy class I'm utilizing to communicate.
My problem is I keep getting a message saying GZip compression is required from the IRS:
The request message must be sent using HTTP compression (RFC 1952 - GZIP). Please review the transmission instructions outlined in Section 5 of Publication 5258, AIR Submission Composition and Reference Guide, located at https://www.irs.gov/e-file-providers/air/affordable-care-act-information-return-air-program, correct any issues, and try again.'
The publication referred to in the error message is very generic and is not specific to .NET and WCF. I did some research and found a way to enable GZip compression in web.config:
<binaryMessageEncoding compressionFormat="GZip" />
However, I now get this error:
The content type text/xml;charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1+gzip). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.
Does anyone know what I'm doing wrong? Do I need to create a custom encoder? Here's is my full web.config file:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.7.2"/>
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="GetACATransmitterStatusReqBinding">
<security mode="Transport" />
</binding>
<binding name="GetACATransmitterStatusReqBinding1" />
</basicHttpBinding>
<customBinding>
<binding name="BulkRequestTransmitterBinding">
<!--<textMessageEncoding messageVersion="Soap11WSAddressing10" />-->
<binaryMessageEncoding compressionFormat="GZip" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://la.www4.irs.gov/airp/aca/a2a/1095BC_Transmission_AATS"
binding="customBinding" bindingConfiguration="BulkRequestTransmitterBinding"
contract="BulkRequestTransmitterService.BulkRequestTransmitterPortType"
name="BulkRequestTransmitterPort" />
<endpoint address="https://la.www4.irs.gov/airp/aca/a2a/1095BC_Status_Request_AATS"
binding="basicHttpBinding" bindingConfiguration="GetACATransmitterStatusReqBinding"
contract="ACAGetTransmitterBulkRequestStatus.ACATransmitterStatusReqPortType"
name="ACATransmitterStatusReqPort" />
</client>
</system.serviceModel>
</configuration>

Related

How can I set message encoding for a web reference

I've been given a service which I need to consume. This service is only happy when added to the project as a 'web reference' and NOT a 'service reference'. When I add the reference, the app.config is modified as shown here...
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TestApp.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<TestApp.My.MySettings>
<setting name="TestApp_DemoService_Rfx" serializeAs="String">
<value>https://www.mydemosourcesite.com:443/common/services/Rfx/</value>
</setting>
</TestApp.My.MySettings>
</applicationSettings>
I can consume the service fine, except that the response it's returning uses MTOM. My question is - how can I configure this service to use MTOM for the message encoding. If I were doing this with a service reference, I'd do this...
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="RfxSOAP" messageEncoding="Mtom">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://www.mydemosourcesite.com:443/common/services/Rfx/" binding="basicHttpBinding" bindingConfiguration="RfxSOAP" contract="DemoService.Rfx" name="RfxSOAP" />
</client>
</system.serviceModel>
Sadly though, I'm not using a service reference and no idea how to get this configured for a web reference! This is in VB and .NET 4.
All help appreciated!

Capture WCF client request with a proxy configuration

I need to capture trafic with fiddler but in my config i need to specify a proxy to perform the connection my .config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="asdClientTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy proxyaddress="http://zzzzz"></proxy>
</defaultProxy>
</system.net>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ATEX">
<security mode="Transport" />
</binding>
<binding name="ATEX1">
<security mode="Transport" />
</binding>
<binding name="ATEX2" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://zzzzzzzz"
binding="basicHttpBinding" bindingConfiguration="ATEX" contract="WS.ConsultaATEX"
name="ATEX" />
</client>
</system.serviceModel>
</configuration>
but fiddler is not capturing nothing.
does anyone help me?
I believe here you will find how to properly configure Fiddler to achieve what you need.
If your server is running locally you may be missing bypassonlocal="False" in the <proxy> tag. I took this information from here.
Hope it helps!

SOAP Create web-server for IIS with BizTalk

I have to configurate SOAP web-service with BizTalk involving
How it must works
1. Client has login/pass going to https://soap.mjr.ru/soap.svc
2. Client send Request like
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:doc="https://docflow.mjr.ru.Request">
<soapenv:Header/>
<soapenv:Body>
<doc:Request>
<MessageIdentifier>1231</MessageIdentifier>
<MessageType>3B18</MessageType>
<MessagePriority>1</MessagePriority>
<XmlRequest>kuehgiuehriveiveibveifbveifbviebfvieb</XmlRequest>
<Sender>123456789</Sender>
<Receiver>123456789</Receiver>
</doc:Request>
</soapenv:Body>
</soapenv:Envelope>
SOAP server at my side receive request and send back to Client answer about good receipt or error code
Server take from inbound message data from Request field and put it like XML into folder
What i have done
In Visual Studio I Have created new BT project with XSD for Request and Response
I have deployed this project into BTS
Within utilite BizTalk WCF service Publishing Wizard I have publicate schemas as service into /soap/soap.svc
Configurate subsite Application Spool by SQL user for DB connection
Create new site in IIS and bind it for https://soap.mjr.ru
Configurate permission for client user for this folder
In BizTalk Server Administrator configurate Receive Port & Receive Location (they have been created automatically). Rewrite address to file from /soap/soap.svc to `/soap.svc'
Run application in BTS and after i can see the file at https://soap.mjr.ru/soap.svc?WSDL
But i can't reach my service with SOAPUI. Here i have 401 error.. and that's all
Please help with correct configuration
listing of web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<section name="bizTalkSettings" type="Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkConfigurationSection,
Microsoft.BizTalk.Adapter.Wcf.Runtime, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<bizTalkSettings>
<mexServiceHostFactory debug="false">
<receiveLocationMappings>
</receiveLocationMappings>
</mexServiceHostFactory>
<webServiceHostFactory debug="false" />
<isolatedReceiver disable="false" />
<btsWsdlExporter disable="false" />
</bizTalkSettings>
<appSettings />
<connectionStrings />
<system.web>
<customErrors mode="Off" />
<compilation defaultLanguage="c#" debug="false">
<assemblies>
<add assembly="mscorlib, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" />
<add assembly="Microsoft.BizTalk.Adapter.Wcf.Common, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="Microsoft.BizTalk.Adapter.Wcf.Runtime, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
<authentication mode="Windows" />
<identity impersonate="false" />
</system.web>
<system.serviceModel>
<extensions><behaviorExtensions><add name="btsWsdlExporter" type="Microsoft.BizTalk.Adapter.Wcf.Metadata.BtsWsdlExporterElement,
Microsoft.BizTalk.Adapter.Wcf.Runtime, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /></behaviorExtensions></extensions>
<bindings>
<basicHttpBinding>
<binding name="httpBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<diagnostics>
<endToEndTracing activityTracing="true" messageFlowTracing="true" propagateActivity="true">
</endToEndTracing>
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviorConfiguration">
<serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkServiceInstance" behaviorConfiguration="ServiceBehaviorConfiguration">
<host>
<baseAddresses>
<add baseAddress="https://10.8.1.226/soap.svc" />
<add baseAddress="https://soap.mjr.ru/soap.svc" />
</baseAddresses>
</host>
<endpoint name="HttpMexEndpoint" address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>

ExchangeServiceBinding, EWS, Exchange Web Service

Currently I'm facing a problem trying to use the EWS, the original requirement is to connect to the mail of a specific user, after that, search for a specific folder, search for a mail and then download the attachment to a specific folder to the local machine so that later it can be processed by Integration Services, I don't want to use the EWS Managed API because I don't want to install anything when migrating to the production server, right now my idea is to develop a WCF service that connects to the EWS service through the .asmx uri and that will be able to fulfill my requirement, right now I'm ok connecting to the company's EWS but I have a few doubts:
According to Microsoft: http://msdn.microsoft.com/en-us/library/exchange/bb408524(v=exchg.150).aspx they say you must add a web service reference to your project, although it only mentions VS 2005 and VS 2008 (I'm working with VS 2012), it should automatically creates the class ExchangeServiceBinding which gives you everything you need in order to impersonate an account, my first question is: why I'm not seeing this class added to my project? should I expect this is because I am using VS 2012?
ok, anyway I'm able to use some methods like getPasswordExpirationTime, but when I use the FindFolder method, I'm getting the error: "The account does not have permission to impersonate the requested user.", this is my method:
using (ExchangeServicePortTypeClient exchangeServicePortTypeClient = new ExchangeServicePortTypeClient())
{
exchangeServicePortTypeClient.ChannelFactory.Endpoint.Address = new EndpointAddress("https://email.kraft.com/EWS/Exchange.asmx");
FindFolderResponseType findFolderResponseType = null;
exchangeServicePortTypeClient.FindFolder(
new ExchangeImpersonationType
{
ConnectingSID = new ConnectingSIDType
{
Item = #"gilberto.gutierrez#mdlz.com",
ItemElementName = ItemChoiceType1.PrimarySmtpAddress
}
},
null,
new RequestServerVersion { Version = ExchangeVersionType.Exchange2010_SP2 },
null,
new FindFolderType
{
FolderShape = new FolderResponseShapeType
{
BaseShape =
DefaultShapeNamesType.Default
}
}, out findFolderResponseType);
}
I have tried to set the credentials through this:
exchangeServicePortTypeClient.ClientCredentials.Windows.ClientCredential.UserName
exchangeServicePortTypeClient.ClientCredentials.Windows.ClientCredential.Password
exchangeServicePortTypeClient.ClientCredentials.Windows.ClientCredential.Domain
exchangeServicePortTypeClient.ChannelFactory.Credentials.Windows.ClientCredential.UserName
exchangeServicePortTypeClient.ChannelFactory.Credentials.Windows.ClientCredential.Password
exchangeServicePortTypeClient.ChannelFactory.Credentials.Windows.ClientCredential.Domain
with no luck :(.
by the way, this is my wcf config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--Diagnostics section, we will only catch error and warning in production-->
<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Error, Warning">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add type="System.Diagnostics.DefaultTraceListener" name="SellOut.ExchangeWcfService">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Error, Warning">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add type="System.Diagnostics.DefaultTraceListener" name="SellOut.ExchangeWcfService">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\Users\LFH2623\Documents\SellOut\SellOut\SellOut.Hosts.ExchangeWcfService\SellOut.ExchangeWcfService_web_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="LogicalOperationStack, DateTime, Callstack">
<filter type="" />
</add>
<add initializeData="C:\Users\LFH2623\Documents\SellOut\SellOut\SellOut.Hosts.ExchangeWcfService\SellOut.ExchangeWcfService_web_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="LogicalOperationStack, DateTime, Callstack">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<!--Framework Section-->
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<!--Web section-->
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="2147483646" />
</system.web>
<!--Web server section-->
<system.webServer>
<directoryBrowse enabled="false"/>
<defaultDocument enabled="true"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<!--WS section-->
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true"
maxMessagesToLog="10000"
logMessagesAtTransportLevel="true"
logMessagesAtServiceLevel="True"
logEntireMessage="true"/>
<endToEndTracing activityTracing="false" />
</diagnostics>
<!--For the ExchangeWebService we will aply the following service and endpoint behaviors-->
<behaviors>
<serviceBehaviors>
<behavior name="ExchangeWebService">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" httpHelpPageEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
<serviceTimeouts transactionTimeout="01:00:00" />
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100" maxConcurrentInstances="100"/>
<serviceDiscovery>
<announcementEndpoints>
<endpoint kind="udpAnnouncementEndpoint"></endpoint>
</announcementEndpoints>
</serviceDiscovery>
</behavior>
</serviceBehaviors>
<!-- Define the corresponding scope for the clients to find the service through resolve message -->
<endpointBehaviors>
<behavior name="ExchangeWebService">
<endpointDiscovery enabled="true">
<scopes>
<add scope="http://SellOut.ExchangeWcfService/"/>
</scopes>
</endpointDiscovery>
</behavior>
</endpointBehaviors>
</behaviors>
<!-- In case you want to scale this service -->
<standardEndpoints>
<!-- We allow the service to be discoverable through the network in an adhoc architecture through UDP -->
<udpDiscoveryEndpoint>
<standardEndpoint name="adhocDiscoveryEndpointConfiguration"
discoveryMode="Adhoc"
discoveryVersion="WSDiscovery11"
maxResponseDelay="00:00:10">
</standardEndpoint>
</udpDiscoveryEndpoint>
<!-- We allow the service to be discoverable through the network in a managed architecture -->
<discoveryEndpoint>
<standardEndpoint name="managedDiscoveryEndpoint" discoveryMode="Managed" maxResponseDelay="00:01:00"/>
</discoveryEndpoint>
<!-- We announce the service with hello & bye -->
<announcementEndpoint>
<standardEndpoint name="udpAnnouncementEndpointConfiguration"
discoveryVersion="WSDiscovery11" />
</announcementEndpoint>
</standardEndpoints>
<!--All the Kraft's clients are .net, so we will use the proprietary binary message encoding to reduce the message's size -->
<bindings>
<customBinding>
<binding name="wsHttpBindingBynaryEncoding"
closeTimeout="00:10:00"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00">
<binaryMessageEncoding>
<readerQuotas maxDepth="32"
maxStringContentLength="5242880"
maxArrayLength="2147483646"
maxBytesPerRead="4096"
maxNameTableCharCount="5242880" />
</binaryMessageEncoding>
<httpTransport
transferMode="Buffered"
maxBufferPoolSize="2147483646"
maxReceivedMessageSize="2147483646">
</httpTransport>
</binding>
</customBinding>
<basicHttpBinding>
<binding name="KraftEWS" messageEncoding="Text" transferMode="Buffered">
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<!-- We reference the Kraft EWS -->
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="KraftEWS"
contract="KraftEWS.ExchangeServicePortType"
name="ExchangeServiceBinding_ExchangeServicePortType">
</endpoint>
</client>
<!--Services section-->
<services>
<service name="SellOut.Services.Exchange.ExchangeWebService" behaviorConfiguration="ExchangeWebService">
<endpoint name="rules"
address="rules"
binding="customBinding"
bindingConfiguration="wsHttpBindingBynaryEncoding"
behaviorConfiguration="ExchangeWebService"
contract="SellOut.Contracts.Exchange.IExchangeRulesContract"/>
<endpoint name="udpDiscovery"
kind="udpDiscoveryEndpoint"
endpointConfiguration="adhocDiscoveryEndpointConfiguration" />
<endpoint name="mex"
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
another thing to mention, in this config:
<basicHttpBinding>
<binding name="KraftEWS" messageEncoding="Text" transferMode="Buffered">
<security mode="Transport">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"></transport>
</security>
</binding>
</basicHttpBinding>
if I remove the part client credential type "Windows", when trying to run the service the exception is :
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
can you guys give me a hand.
Thanks in advice.
I highly suggest that you use the EWS Managed API for this. I don't understand what you mean when you state that you don't want to install anything on the production server since you will have to install the WCF service on your production server, along with the object model created by the Add Web Service reference project. But, it looks like you got passed this part, so let's move on....
Excellent, good to know that you could call getPassowrdExpirationTime. Thank you for providing me that info.
The reason why you get the message "The account does not have permission to impersonate the requested user" is because the account that runs your WCF service doesn't have impersonation rights to the mailbox. You will need to setup Exchange impersonation before your service account can access the user's account. Once your service has credentials that Exchange can lookup in AD (which it already does), and it has rights to impersonate your users (which is on your TODO list), your code should work since authentication is done based on the service account's identity.
All parts of your question after your code example are not in scope. You don't need to make any changes to the web.config (at least I don't think so). I assume that you are testing against an on-premise server since the Auth schemes were Negotiate and NTLM.
With regards,
The article you linked to

Why does this WCF call fail when passing in a federated security token

I'm trying to pass a security token from a client application into a WCF service for authentication.
For this example I'm just using the standard File, New WCF Application project and trying to call the GetData method.
I get the following exception on the client
{"The message could not be processed. This is most likely because the
action 'http://tempuri.org/IService1/GetData' is incorrect or because
the message contains an invalid or expired security context token or
because there is a mismatch between bindings. The security context
token would be invalid if the service aborted the channel due to
inactivity. To prevent the service from aborting idle sessions
prematurely increase the Receive timeout on the service endpoint's
binding."}
If I enable tracing on the WCF service I can see the following error
There was no channel that could accept the message with action
'http://tempuri.org/IService1/GetData'.
The Web.Config for my service looks like this
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<!--Configure STS-->
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="https://stsserver.security.int/myApp" />
</audienceUris>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
<trustedIssuers>
<add thumbprint="‎3c8fc34bd483b07ba0d1509827fc4788c36247e4" name="StartSSL Login" />
</trustedIssuers>
</issuerNameRegistry>
<certificateValidation certificateValidationMode="None"/>
</identityConfiguration>
</system.identityModel>
<system.serviceModel>
<bindings>
<ws2007FederationHttpBinding>
<binding name ="IdentityServer">
<security mode="TransportWithMessageCredential">
</security>
</binding>
</ws2007FederationHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="Services.Service1" behaviorConfiguration="CertificateBehavior">
<endpoint name="ws" binding="ws2007FederationHttpBinding" bindingConfiguration="IdentityServer" contract="Services.IService1" address=""/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CertificateBehavior">
<serviceCredentials>
<serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The method in my client application that calls this WCF service looks like this
static void CallSecuredService(SecurityToken samlToken)
{
var binding = new WS2007FederationHttpBinding((WSFederationHttpSecurityMode.TransportWithMessageCredential));
binding.Security.Message.IssuedKeyType = SecurityKeyType.BearerKey;
binding.Security.Message.EstablishSecurityContext = false;
var factory = new ChannelFactory<IService1>(binding, new EndpointAddress("https://localhost/myservice/Service1.svc"));
factory.Credentials.SupportInteractive = false;
factory.Credentials.UseIdentityConfiguration = true;
var proxy = factory.CreateChannelWithIssuedToken(samlToken);
Console.WriteLine(proxy.GetData(1));
}
Any pointers as to things I should check would be great as I'm at a bit of a loss with this one now. I'm not sure how I can debug this any further?
I finally managed to get past this error. The problem was a small miss match between the service and client bindings.
Changing my bindings in the web.config to this fixed the issue
<bindings>
<ws2007FederationHttpBinding>
<binding name ="IdentityServer">
<security mode="TransportWithMessageCredential">
<message issuedKeyType="BearerKey" establishSecurityContext="false"/>
</security>
</binding>
</ws2007FederationHttpBinding>
</bindings>