Hi all,
I need to consume a WCF Web Service which returns a composed type which is a list of objects with the following structure:
[Serializable]
publicclassTitle
{
public Title()
{
ExternalLibraryID = string.Empty;
}
publicstring TitleID { get;set; }
publicstring ItemID { get; set; }
publicstring Country { get;set; }
publicstring Language { get;set; }
publicstring Description { get;set; }
publicstring ExternalLibraryID { get;set; }
publicstring Runtime { get;set; }
publicstring DueDate { get;set; }
}
The definition of the service is this:
namespace TestServiceWCF
{
[ServiceContract]
publicinterfaceITestServiceService
{
[OperationContract]
TestServiceResponse GetTitles(TestServiceRequest request);
}
[DataContract]
publicclass TestServiceRequest
{
[DataMember]
publicstring FilePath { get;set; }
[DataMember]
publicCustomers Customer { get;set; }
}
[DataContract]
publicclass TestServiceResponse
{
[DataMember]
publicList<Title> Titles { get; set; }
}
}
If I am testing the web service from a .NET client everything works just well because I am able to serialize the response of the web service and write it to a file using :
XmlSerializer x = newXmlSerializer(response.GetType());
using (TextWriter writer = newStreamWriter(fileName))
{
x.Serialize(writer, response);
writer.Flush();
}
I am trying to do the same thing in AX but it seems that the response object is NULL when tested with
CLRInterop::IsNull(response)
method and the processing of the response is interrupted.
I found on this forum, an older post from Mohammed Rasheed saying that the response of the web service should be collected in a CLRObject and the transferred to a AX container with
con = ClrInterop::getAnyTypeForObject(clrObject);
I've tried that also but I'm getting errors like this when I am trying to get the web service response directly into a ClrObject type variable.
Type 'System.ServiceModel.Channels.ReceivedFault' in assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
It looks like I need to set something more on the web service configuration but I do not know what exactly.
Any help will be greatly appreciated.
Best regards,
Sorin