Viene visualizzato un errore "stato anomalo" quando si utilizza il servizio principale in SDL Tridion 2011 SP1. Cosa c'è di sbagliato in quanto segue?Errore di stato in errore durante la creazione del componente con il servizio principale
namespace coreservice1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
using (ChannelFactory<ISessionAwareCoreService> factory =
new ChannelFactory<ISessionAwareCoreService>("wsHttp_2011"))
{
ISessionAwareCoreService client = factory.CreateChannel();
string SCHEMA_URI = "tcm:7-426-8";
var schemaFields = client.ReadSchemaFields(SCHEMA_URI, true, new ReadOptions());
foreach (var field in schemaFields.Fields)
{
Response.Write(string.Format("{0}", field.Name));
}
Response.Write(schemaFields.NamespaceUri);
string NEW_COMPONENT_FOLDER_URI = "tcm:8-15-2";
Tridion.ContentManager.CoreService.Client.ComponentData component = new Tridion.ContentManager.CoreService.Client.ComponentData
{
Schema = new LinkToSchemaData { IdRef = "tcm:8-426-8"},
Title = "Helloworldalll",
Id = "tcm:0-0-0",
LocationInfo = new LocationInfo
{
OrganizationalItem =
new LinkToOrganizationalItemData { IdRef = NEW_COMPONENT_FOLDER_URI}
},
};
string namespaceUri = schemaFields.NamespaceUri;
System.Text.StringBuilder content = new StringBuilder();
string First = "Hello World.This is Fisrt field";
content.AppendFormat("<{0} xmlns=\"{1}\">", schemaFields.RootElementName, namespaceUri);
content.AppendFormat("<{0} xmlns=\"{1}\">{2}</{0}>", "first", namespaceUri, First);
content.AppendFormat("</{0}>", schemaFields.RootElementName);
component.Content = content.ToString();
ComponentData comp = (ComponentData)client.Create(component, new ReadOptions());
string newlyCreatedComponentID = comp.Id;
Response.Write("Hello hai");
Response.Write("Id of newly created component: " + newlyCreatedComponentID);
}
}
catch (Exception ex)
{
Response.Write(ex.StackTrace);
Response.Write("exception is " + ex.Message);
}
}
}
}
“presso System.ServiceModel.Channels.CommunicationObject.Close (TimeSpan timeout) a System.ServiceModel.Channels.ServiceChannelFactory.OnClose (TimeSpan timeout) a System.ServiceModel.Channels.ServiceChannelFactory.TypedServiceChannelFactory`1 .OnClose (TimeSpan timeout) su System.ServiceModel.Channels.CommunicationObject.Close (timeout TimeSpan) su System.ServiceModel.ChannelFactory.OnClose (timeout TimeSpan) su System.ServiceModel.Channels.CommunicationObject.Close (timeout TimeSpan) su System.ServiceModel .ChannelFactory.System.IDisposable.Dispose() su coreservice1._Default.Page_Load (Object mittente, EventArgs e) in D: \ SampleProjects_Tridion \ test \ coreservice1 \ coreservice1 \ coreservice.aspx.cs: line 73exception is The communicatio n oggetto, System.ServiceModel.Channels.ServiceChannel, non può essere utilizzato per la comunicazione perché è in stato di errore. “
"L'oggetto di comunicazione, System.ServiceModel.Channels.ServiceChannel, non può essere utilizzato per la comunicazione perché è in stato di errore." Ciò significa che si è verificato un errore durante l'esecuzione del codice e non l'hai gestito correttamente. Puoi condividere il codice che hai usato? Vale anche la pena controllare questo post di Peter: http://pkjaer.wordpress.com/2011/11/30/core-service-clients-and-the-using-statement/ –
@NunoLinhares. Ho aggiornato il codice. Plz ci ha pensato. – Patan
Il codice è abbastanza utile. Puoi per favore indicare quale linea è # 73? Il messaggio di errore punta alla riga 73, ma non riesco a mapparlo a questo frammento di codice. –