Tridion 2011 CoreService Connection
Asked Answered
S

4

6

I am using Tridion 2011 SP1 and am connecting to the CoreService using the code from here:

http://code.google.com/p/tridion-practice/wiki/GetCoreServiceClientWithoutConfigFile

But when i try to do any simple operation, such as this:

XElement resultXml = _coreService.GetListXml(publicationId, filterData);

I get the below error message.

"{"The message with Action 'http://www.sdltridion.com/ContentManager/CoreService/2011/ICoreService/Create' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None)."}"

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 response's Nuno & Frank, i have it working now by adding a service reference, just a bit curious why my code didn't work though because it creates the below bindings, which are, as far as i can see (and i may well have missed something) the same the code above
Nuno's approach also works - thanks Nuno.

<basicHttpBinding> <binding name="basicHttp_2010"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" /> </security> </binding> </basicHttpBinding>

Sclaff answered 18/9, 2012 at 19:32 Comment(0)
C
5

This is not the answer to your question, but here's how I deal with Core Service clients nowadays:

  1. Add a reference to [Tridion]\bin\client\Tridion.ContentManager.CoreService.Client.dll
  2. Copy the contents of [Tridion]\bin\client\Tridion.ContentManager.CoreService.Client.dll.Config into my own app.config

Then in code just do this:

SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient("netTcp_2011");

Done.

PS - On Frank's suggestion, added this to the Tridion Practice wiki: http://code.google.com/p/tridion-practice/wiki/GetCoreServiceClientWithConfigFile

Chickenlivered answered 18/9, 2012 at 19:48 Comment(0)
H
3

It looks like the bindings you create are not in-line with what the server expects. Have a look at the .config on your TCM server and make sure that the client-side creates the same type of binding.

Hendren answered 18/9, 2012 at 19:48 Comment(0)
A
1

You are connecting to the wrong endpoint. You cannot connect to the "2010" version of the Core Service using a "2011" client.

You should connect to the 2011 endpoint instead (.../webservices/CoreService2011.svc/basicHttp)

Of course, you could alternatively change your reference to the 2010 version of the client but I wouldn't do that unless you run into issues.

Andonis answered 24/9, 2012 at 14:23 Comment(0)
O
0

I fixed this same error by changing /CoreService/2012/ to /CoreService/2013/ in my app config here:

<endpoint name="netTcp_2012" address="net.tcp://localhost:2660/CoreService/2013/netTcp" binding="netTcpBinding" bindingConfiguration="netTcp" contract="Tridion.ContentManager.CoreService.Client.ISessionAwareCoreService" />

I suspect I originally created my core service app in Tridion 2011, and then I was trying to run it with Tridion 2013.

Overuse answered 2/3, 2016 at 20:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.