I am using Tridion 2011 SP1 and connecting to CoreService using the code here:
http://code.google.com/p/tridion-practice/wiki/GetCoreServiceClientWithoutConfigFile
But when I try to perform any simple operation, for example:
XElement resultXml = _coreService.GetListXml(publicationId, filterData);
I get the following error message.
"{" Message with action "http://www.sdltridion.com/ContentManager/CoreService/2011/ICoreService/Create 'cannot be processed at the receiver due to a ContractFilter mismatch in the EndpointDispatcher. This may be due to a contract mismatch ( mismatch between the sender and the recipient) or a binding / security mismatch between the sender and the recipient. Make sure that the sender and the recipient have the same contract and the same binding (including security requirements, such as message, transport, no). " } "
Any ideas?
Full code here:
RepositoryItemsFilterData filterData = new RepositoryItemsFilterData(); filterData.ItemTypes = new[] { ItemType.Component, ItemType.Schema }; filterData.Recursive = true; ICoreService _coreService = GetNewClient(); XElement resultXml = _coreService.GetListXml(publicationId, filterData); private ICoreService GetNewClient() { var binding = new BasicHttpBinding() { MaxBufferSize = 4194304, // 4MB MaxBufferPoolSize = 4194304, MaxReceivedMessageSize = 4194304, ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() { MaxStringContentLength = 4194304, // 4MB MaxArrayLength = 4194304, }, Security = new BasicHttpSecurity() { Mode = BasicHttpSecurityMode.TransportCredentialOnly, Transport = new HttpTransportSecurity() { ClientCredentialType = HttpClientCredentialType.Windows, } } }; _hostname = string.Format("{0}{1}{2}", _hostname.StartsWith("http") ? "" : "http://", _hostname, _hostname.EndsWith("/") ? "" : "/"); var endpoint = new EndpointAddress(_hostname + "webservices/CoreService.svc/basicHttp_2010"); ChannelFactory<ICoreService> factory = new ChannelFactory<ICoreService>(binding, endpoint); factory.Credentials.Windows.ClientCredential = new System.Net.NetworkCredential(_username, _password); return factory.CreateChannel(); }
UPDATE: Thanks for the answer from Nuno and Frank, I now have a job adding a link to the service, just a little curious why my code didn’t work, because it creates below bindings which, as far as I can see (and I maybe, that- then missed), same code above
Nuno's approach also works - thanks Nuno.
<basicHttpBinding> <binding name="basicHttp_2010"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" /> </security> </binding> </basicHttpBinding>