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]
public class Title
{
public
Title()
{
ExternalLibraryID = string.Empty;
}
public string TitleID { get;
set; }
public string ItemID { get; set; }
public string Country { get;
set; }
public string Language { get;
set; }
public string Description { get;
set; }
public string ExternalLibraryID { get;
set; }
public string Runtime { get;
set; }
public string DueDate { get;
set; }
}
The definition of the service is this:
namespace TestServiceWCF
{
[ServiceContract]
public interface ITestServiceService
{
[OperationContract]
TestServiceResponse
GetTitles(TestServiceRequest request);
}
[DataContract]
public class TestServiceRequest
{
[DataMember]
public string FilePath { get;
set; }
[DataMember]
public Customers Customer { get;
set; }
}
[DataContract]
public class TestServiceResponse
{
[DataMember]
public List<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 = new XmlSerializer(response.GetType());
using (TextWriter writer = new
StreamWriter(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