Я пишу ниже кода, чтобы создать компонент MM в tridion через основное обслуживание, но я получаю ошибку управлять этим обслуживанием,
public ComponentData GetNewMultimediaComponent(CoreServiceClient Client, string folderUri, string schemaUri, string title, FileInfo fi)
{
if (fi.Extension == ".png")
{
string mmType = GetMultiMediaType(fi.Extension);
if (mmType != null)
{
string tempLocation = "";
UploadResponse us = new UploadResponse();
using (StreamUploadClient streamClient = GetConnection())
{
FileStream objfilestream = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read);
tempLocation = streamClient.UploadBinaryContent(fi.Name.ToLower(), objfilestream);
}
BinaryContentData bcd = new BinaryContentData
{
UploadFromFile = fi.FullName,
MultimediaType = new LinkToMultimediaTypeData { IdRef = mmType },
Filename = fi.Name,
IsExternal = false
};
ComponentData res = GetNewComponent(folderUri, schemaUri, title);
res.ComponentType = ComponentType.Multimedia;
res.BinaryContent = bcd;
res = (ComponentData)Client.Create(res, new ReadOptions());
В вышеупомянутом коде я надеваю ошибку ниже линии
using (StreamUploadClient streamClient = new StreamUploadClient())
{System.InvalidOperationException: Could not find default endpoint element that references contract 'Tridion.ContentManager.CoreService.Client.IStreamUpload' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait).......
Только для обновления, я использую tridion основные услуги DLL без файла конфигурации и создаю связь успешно.
Настройка подключения
public StreamUploadClient GetConnection()
{
BasicHttpBinding basicHttpBinding = new BasicHttpBinding
{
MaxReceivedMessageSize = 10485760,
ReaderQuotas = new XmlDictionaryReaderQuotas
{
MaxStringContentLength = 10485760,
MaxArrayLength = 10485760
},
Security = new BasicHttpSecurity
{
Mode = BasicHttpSecurityMode.None,
}
};
EndpointAddress remoteAddress = new EndpointAddress("http://abc/webservices/CoreService2011.svc/streamUpload_basicHttp");
StreamUploadClient client = new StreamUploadClient(basicHttpBinding, remoteAddress);
try
{
client.Open();
}
catch (Exception ex)
{
//log.Error("Error:CoreServiceConectionOpen:Common:" + ex.Message);
throw ex;
}
return client;
}
Теперь, надевая ошибку ниже линии
tempLocation = streamClient.UploadBinaryContent(fi.Name.ToLower(), objfilestream);
{System.ServiceModel.ProtocolException: The content type multipart/related; type="application/xop+xml";start="";boundary="uuid:739a821f-aee2-4eaf-9206-05a1ed19311c+id=1";start-info="text/xml" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 560 bytes of the response were: '
--uuid:739a821f-aee2-4eaf-9206-05a1ed19311c+id=1
Content-ID:
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
C:\Windows\TEMP\tmp6841.png
--uuid:739a821f-aee2-4eaf-9206-05a1ed19311c+id=1--
'.
Кто-либо может помочь мне решить этот вопрос?